psdi.app.invoice

Class Invoice

  • All Implemented Interfaces:
    java.rmi.Remote, InvoiceRemote, InvoiceAppActionInterface, MboConstants, MboRemote, StatefulMboRemote, MaxRemoteProxy


    public class Invoice
    extends StatefulMbo
    implements InvoiceRemote
    Mbo object to represent Invoice. An invoice is a financial document that is normally sent by a supplier/vendor organization to a buyer organization, listing the goods/services that the vendor supplied to the buyer and the value of those goods/services, including any charges (Shipping & Handling, Taxes) that might apply. The invoice is a financial document, and creates an accounts payable liability in the receving organization. The invoice object contains all the header information for that particular invoice like the PO against which it is created, vendor information, the currency code used, the total cost, total taxes, etc;

    See Invoice Package description.

    The key attribute for this object is InvoiceNum.

    The attributes in this object are as follows:

    Attribute NameAttribute Description
    APControlAcctThe credit account of the vendor used when the invoice is paid.
    ApprovalNumAuto generated number on approval of invoice.
    APSuspenseAcctThe credit account of the vendor used when the invoice is approved.
    BankAccountThe company's bank account to which direct payments can be sent.
    BankNumThe company's bank and branch identification reference number, used when transferring funds electronically.
    BaseTotalCostThe total cost of the invoice expressed in the base currency.
    ChangeByThe name or user ID of the person who last modified the invoice.
    ChangeDateThe date and time when invoice definition was last modified.
    CheckCodeCode indicating how to prepare the check.
    CheckNumNumber of the check used to pay the vendor.
    ContactName of the primary person to contact at the vendor.
    CurrencyCodeThe currency in which the invoice will be paid. Foreign key to Currency.
    DescriptionDescription or purpose of the invoice.
    DiscountDiscount applied if the invoice is paid by the discount date.
    DiscountDateDate by which the invoice must be paid to qualify for the discount.
    DocumentTypeThe type of invoice document: CREDIT, DEBIT or INVOICE.
    DueDateDate by which the payment is due.
    EInvoiceYes/No field indicating whether electronic invoice is received.
    EnterByThe name or user ID of the person who created the invoice.
    EnterDateDate and time the invoice was created.
    ExchangeDateDate the exchange rate was applied.
    ExchangeRateCurrency exchange rate (base currency 1) at the time of invoice approval.
    ExchangeRate2Currency exchange rate (base currency 2) at the time of invoice approval.
    ExternalRefIDExternal Reference ID.
    FinancialPeriodThe open financial period during which the invoice was approved.
    GLPostDateDate used to determine financial period.
    HistoryFlagYes/No field indicating whether the invoice is open or closed.
    Inclusive1 - Inclusive5Yes/No fields indicating whether the vendor is authorized to collect tax.
    InvoiceDateDate on the invoice received from the vendor.
    InvoiceNumCode used to identify the invoice. Unique identifier of this object.
    LDKeyLong Description Key.
    OrgIDOrganization Identifier.
    OrigInvoiceNumIdentifier for the original invoice for the items you want to return, if the type field is credit. Foreign key to Invoice.
    OwnerSysIDOwner system ID.
    PaidThe amount paid to the vendor.
    PaidDateDate on which the invoice was paid.
    PaymentTermsForms of payments accepted by the vendor.
    PONumPurchase Order (PO) for this invoice, if one exists. Foreign key to PO.
    PreTaxTotal (non-persistant)Total cost of the goods invoiced, excluding taxes.
    SenderSysIDColumn used by ERP-Integration (APIs).
    SiteIDOrganization Identifier.
    SourceSysIDSource system ID.
    StatusThe current status of the invoice.
    StatusDateDate and time when the invoice was changed to the current status.
    SysCodeSystem flag required for user data entry.
    Tax1GL - Tax5GLGeneral Ledger account to which the tax will be applied.
    TotalCostTotal cost for the invoice, including taxes and standard service costs.
    TotalTax1 - TotalTax5Total tax of tax type 1 to 5, applied to the invoice.
    VendorIdentifier of the vendor to whom the remittance will be sent. Foreign key to Company.
    VendorInvoiceNumVendor's invoice number.
    WFActiveYes/No field indicating whether Work Flow is active on this invoice.
    WFIDWork Flow identification number.
    • Field Detail

      • uninvoicedReceiptsInfo

        public Invoice.UninvoicedReceiptsInfo uninvoicedReceiptsInfo
        In-memory representation of the uninvoiced receipts for the PO of this invoice. It will be initialized in method getAllUninvoicedReceipts(). It will be destroyed when this invoice is saved.
    • Constructor Detail

      • Invoice

        public Invoice(MboSet ms)
                throws java.rmi.RemoteException
        Construct the Invoice object.
        Parameters:
        ms -
        Throws:
        java.rmi.RemoteException
    • Method Detail

      • getProcess

        public java.lang.String getProcess()
        Return the work flow process for invoice.
      • init

        public void init()
                  throws MXException
        Initialize rountine. Set certain fields to read/only according to the invoice's state, and set the record and its lines to readonly if the status of the invoice is APPR, CANCEL or PAID. Load the syscode value to the internal data structure from the database.
        Overrides:
        init in class Mbo
        Throws:
        java.rmi.RemoteException
        MXException
      • initRelationship

        public void initRelationship(java.lang.String relationName,
                                     MboSetRemote mboSet)
                              throws MXException,
                                     java.rmi.RemoteException
        Called whenever a relationship is initialized or reset from this Mbo to another MboSet. Set the editibility of the Mbos related to the invoice. The initRelationship() is used only when the relationship name that is specified inside this method is used to obtain the target MboSet.
        Overrides:
        initRelationship in class Mbo
        Parameters:
        relationName - the relationship name
        mboSet - the mboset
        Throws:
        MXException
        java.rmi.RemoteException
      • setRelatedMboEditibility

        public void setRelatedMboEditibility(java.lang.String relationName,
                                             MboSetRemote mboSet)
                                      throws MXException,
                                             java.rmi.RemoteException
        Sets the read/only flag for the related set if the set exists only when the status of the invoice is paid - Issue 10-12042.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Invoice.setEditibilityFlags()
      • setCompanyValues

        public void setCompanyValues()
                              throws MXException,
                                     java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getExternalStatus

        public java.lang.String getExternalStatus(java.lang.String internalStatus)
                                           throws java.rmi.RemoteException,
                                                  MXException
        From the internal string of the invoice status value, get the external string of the status.
        Parameters:
        inernalstatus - The status as represented inside MAXIMO. For example APPR, WAPPR, etc;
        Returns:
        String
        Throws:
        java.rmi.RemoteException
        MXException
      • isSyscodeSet

        public boolean isSyscodeSet(long field)
                             throws MXException,
                                    java.rmi.RemoteException
        Check if the field is set by external user.
        Parameters:
        field - one of the values specified in InvoiceSysCode. It can be: TOTALCOST, PRETAXTOTAL, TOTALTAX1, TOTALTAX2, TOTALTAX3, TOTALTAX4, TOTALTAX5, and INVOICELINE.
        Returns:
        boolean True if the the field of as indicated in the parameter is set by external user.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #InvoiceSysCode
      • setSyscode

        public void setSyscode(long field)
                        throws MXException,
                               java.rmi.RemoteException
        Set syscode to indicate the field as specified by the parameter is set by external user.
        Parameters:
        field - one of the values specified in InvoiceSysCode. It can be: TOTALCOST, PRETAXTOTAL, TOTALTAX1, TOTALTAX2, TOTALTAX3, TOTALTAX4, TOTALTAX5, and INVOICELINE.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #InvoiceSysCode
      • clearSyscode

        public void clearSyscode(long field)
                          throws MXException,
                                 java.rmi.RemoteException
        Clear the syscode to indicate the field as specified by the parameter is set by external user.
        Parameters:
        field - one of the values specified in InvoiceSysCode. It can be; TOTALCOST, PRETAXTOTAL, TOTALTAX1, TOTALTAX2, TOTALTAX3, TOTALTAX4, TOTALTAX5, and INVOICELINE.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #InvoiceSysCode
      • add

        public void add()
                 throws MXException,
                        java.rmi.RemoteException
        This is called when a new invoice is added to the Invoice MboSet collection. The field defaults and field flags are set here. The table below shows the default values for each of the attributes listed.
        Attribute NameAttribute Value
        basetotalcost0.0(zero)
        changebyCurrent username
        changedateCurrent date
        currencycodeBase currency 1
        documenttypeINVOICE
        einvoiceNo
        enterbyCurrent username
        enterdateCurrent date
        exchangerate1(One)
        glpostdateCurrent date
        historyflagNo
        inclusive1..5No
        invoicenumAuto Key
        statusENTERED
        statusdateCurrent date
        syscode0(Zero)
        totalcost0.0(Zero)
        totaltax1..50.0(Zero)
        Specified by:
        add in interface MboRemote
        Overrides:
        add in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • setEditibilityFlags

        protected void setEditibilityFlags()
        Set the read-only flags for fields when the record is added.
      • generateAutoKey

        public void generateAutoKey()
                             throws java.rmi.RemoteException,
                                    MXException
        Invoice supports autokeying - sets the INVOICENUM attribute. This method is only to be called when we are enforcing autokeying the invoicenum attribute. Only autokey if the attibute is null as it may already be autokeyed by the framework. Only allowed for newly created invoice.
        Specified by:
        generateAutoKey in interface MboRemote
        Overrides:
        generateAutoKey in class Mbo
        Throws:
        MXAccessException - (access, CantGenAutoKey) Cannot generate auto key.
        java.rmi.RemoteException
        MXException
        See Also:
        MboValue.autoKey(), MboValue.generateUniqueID()
      • modify

        public void modify()
                    throws MXException,
                           java.rmi.RemoteException
        This is called whenever a change is made to the attributes of invoice. When any field realated to invoice is changed, changedate and changeby is updated.
        Overrides:
        modify in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • validateForApproval

        public void validateForApproval()
                                 throws MXException
        Validate the invoice right before approval. It is called by the status handler of the invoice. It checks the following:
        1. General validations including there should be invoicelines for this invoice, totalcost cannot be 0, status has to be wait for approval, entered, or hold. Each invoiceline cannot have quantity equal to 0 if not service line.
        2. Reset exchangerate, exchangerate2 of invoice according to the current exchangerate, and in turn calculate the linecost2. Also set the financial period.
        3. Currency validation. The invoice's currency should have proper exchange rate to PO and base currencies.
        4. Receipt status validation. If receipt required, service receipt has to be approved before invoice can be approved.
        5. The status of work order on invoicecost cannot be canceled or waiting for approval.
        6. Check for invoicematch. Matches have to be found for each invoiceline.
        7. Check for tax prorating. Taxcode has to exist if tax difference needs to be prorated.
        8. Based on a maxvar value check if the pocost's GL debit and credit accounts are required for this transaction.
        Throws:
        MXApplicationException - (invoice, NoLines) No invoice lines.
        MXApplicationException - (invoice, TotalCostZero) Total cost is zero.
        MXApplicationException - (invoice, StatusInvalidForApproval) Invalid status.
        MXApplicationException - (invoice, InvoiceLineQtyZero) Invoice line quantity is zero.
        MXApplicationException - (invoice, InvoiceApproval) Invoice cannot be approved.
        MXApplicationException - (financial, GLRequiredForTrans) The debit and credit GL accounts for invoicecosts require a value.
        MXException
      • appValidate

        public void appValidate()
                         throws MXException,
                                java.rmi.RemoteException
        This method is called by the framework before save. If the invoice syscode indicates that the totaltax, pretaxtotal, totalcost are not set by the user, the totals should be the sum of the value on each invoice line. If not, calculate the totals. The reason to have this logic is to provide an easy way for receipt to create invoice. When invoice is created by the receipt, all information on the invoiceline is set with NOVALIDATION_AND_NOACTION, because calculation is already done by receiving. However, the total information on the invoice header is not set. This method is used to handle this and similar situations.
        Overrides:
        appValidate in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • checkForServiceLinePOTolerance

        public void checkForServiceLinePOTolerance()
                                            throws MXException,
                                                   java.rmi.RemoteException
        For each INVOICELINE that refers to a POLINE with tolerance set, a check is made to ensure that the quantity or cost on the INVOICEL is not greater than the quantity or cost specified on the POLINE.
        Specified by:
        checkForServiceLinePOTolerance in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • checkForPOLineTolerance

        public void checkForPOLineTolerance()
                                     throws MXException,
                                            java.rmi.RemoteException
        For each INVOICELINE that refers to a POLINE, a check is made to ensure that the cost on the INVOICE is not too different from the cost specified on the POLINE. This check is made based on the values specified for the TOLERANCE.UPPERINVOICEPCT / TOLERANCE.LOWERINVOICEPCT and TOLERANCE.UPPERINVOICEAMT / TOLERANCE.LOWERINVOICEAMT attributes. Tolerance Checking is always done in base currency (BASE1).
        Specified by:
        checkForPOLineTolerance in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • checkForServiceLineTolerance

        public void checkForServiceLineTolerance()
                                          throws MXException,
                                                 java.rmi.RemoteException
        The ratio of service lines that do not refer to a PO-POLINE on the INVOICE, to the sum of all the other lines that have a PO reference is checked to ensure that it does not go beyond the values specified by TOLERANCE.UPPERPOAMT / TOLERANCE.LOWERPOAMT and TOLERANCE.UPPERPOPCT / TOLERANCE.LOWERPOPCT. The idea is to ensure that the user does not enter a total value on the invoice that exceeds the total value on the PO. This prevents the user from authorizing too much money for items such as freight or installation costs. The folowing checks are being done:
        1. Raise error if Special Charge Total > UPPERSERVICEAMT, where UPPERSERVICEAMT is NOT NULL.
        2. Raise error if Special Charge Total < LOWERSERVICEAMT, where LOWERSERVICEAMT is NOT NULL.
        3. Raise error if Special Charge Total > PO Total * UPPERSERVICEPCT, where UPPERSERVICEPCT is NOT NULL.
        4. Raise error if Special Charge Total < PO Total * LOWERSERVICEPCT, where LOWERSERVICEPCT is NOT NULL.
        Specified by:
        checkForServiceLineTolerance in interface InvoiceRemote
        Throws:
        MXApplicationException - (invoice, ExceedServiceTolerance) Exceeds allowed service tolerance.
        MXApplicationException - (invoice, LessThanServiceTolerance) Less than allowed service tolerance.
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • checkForTaxTolerance

        public void checkForTaxTolerance()
                                  throws MXException,
                                         java.rmi.RemoteException
        If the user has entered any taxes on the invoice header i.e. if any of the values TOTALTAX1..5 have been specified by the user (determined by the SYSCODE), than this routine will check to ensure that the tax value entered is within allowable tolerance limits as specified by TOLERANCE.UPPERTAXAMT / TOLERANCE.LOWERTAXAMT and TOLERANCE.UPPERTAXPCT / TOLERANCE.LOWERTAXPCT. If no TOTALTAX value has been specified by the user, than no checking is required. The folowing checks are being done:
        1. Raise error if Tax Diff > UPPERTAXAMT, where UPPERTAXAMT is NOT NULL.
        2. Raise error if Tax Diff < LOWERTAXAMT, where LOWERTAXAMT is NOT NULL.
        3. Raise error if Tax Diff > Sum of Tax * UPPERTAXPCT, where UPPERTAXPCT is NOT NULL.
        4. Raise error if Tax Diff < Sum of Tax * LOWERTAXPCT, where LOWERTAXPCT is NOT NULL.
        Specified by:
        checkForTaxTolerance in interface InvoiceRemote
        Throws:
        MXApplicationException - (invoice, ExceedTaxTolerance) Exceeds allowed tax tolerance.
        MXApplicationException - (invoice, LesThanTaxTolerance) Less than allowed tax tolerance.
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • totalInclusiveTax

        public double totalInclusiveTax()
                                 throws MXException,
                                        java.rmi.RemoteException
        Calculates the total tax based on the inclusive tax flags.
        Specified by:
        totalInclusiveTax in interface InvoiceRemote
        Returns:
        double The total inclusive tax.
        Throws:
        MXException
        java.rmi.RemoteException
      • approve

        public void approve()
                     throws MXException
        Approve the invoice. This is called by the status handler after the invoice is validated and allowed to be approved. This method further processes the invoice before actually writing the transactions and changing its status. The invoice approval process involves:
        1. If any cost values (TAX, TOTALCOST or PRETAXTOTAL) have been entered on the INVOICE header (check SYSCODE), than the Pre-Tax total on the invoice header has to be compared with the sum of all the LINECOST on the invoice lines. If these do not match, than the difference has to be adjusted on the lines by recalculating the linecost and also recalculating the tax.
        2. If a value has been specified for any of the TOTALTAX attributes on the invoice header, if there is a difference between the sum of INVOICELINE.TAX1..5 and the corresponding TOTALTAX1..5, then the difference needs to be applied to the invoice lines. This difference is applied as a ratio of the sum of each tax to the tax value on the corresponding line.
        3. If there are lines with PRORATESERVICE = Y, and PRORATED = N, than these values need to be prorated across the other lines on the INVOICE. The PRORATECOST for each line is calculated, and also LOADEDCOST based on the prorate value.
        4. Check for POLine tolerance. For each INVOICELINE that refers to a POLINE, a check is made to ensure that the cost on the INVOICE is not too different from the cost specified on the POLINE.
        5. Check for service line tolerance. For each INVOICELINE that refers to a POLINE, a check is made to ensure that the cost on the INVOICE is not too different from the cost specified on the POLINE.
        6. Check for tax tolerance. If the user has entered any taxes on the invoice header i.e. if any of the values TOTALTAX1..5 have been specified by the user, than this routine will check to ensure that the tax value entered is within allowable tolerance limits.
        7. Check for the approval limit for the invoice.
        8. Writing invoice transactions, receipt transactions for variance adjustment taxes adjustment, and distribute costs.
        9. Update workorder's actual costs.
        10. Generate approval number.
        11. Close the related PO.
        Throws:
        MXException
      • setExchangeRateLineCost2

        public void setExchangeRateLineCost2()
                                      throws MXException,
                                             java.rmi.RemoteException
        Calculate and set the exchangerates and the linecost2. The exchangerate2 and linecost2 are only calculated if there is a basecurrency2.
        Throws:
        MXException
        java.rmi.RemoteException
      • prorateTotalTaxDifference

        public void prorateTotalTaxDifference()
                                       throws MXException,
                                              java.rmi.RemoteException
        Once the taxes have been re-calculated, if a value has been specified for any of the TOTALTAX attributes on the invoice header, and if there is a difference between the sum of INVOICELINE.TAX1..5 and the corresponding TOTALTAX1..5, then the difference needs to be applied to the invoice lines. This difference is applied as a ratio of the sum of each tax to the tax value on the corresponding line. The lines with prorateservice = Y not considered.
        Throws:
        MXException
        java.rmi.RemoteException
      • calcIntermediateLoadedCost

        public void calcIntermediateLoadedCost()
                                        throws MXException,
                                               java.rmi.RemoteException
        Once the tax values are calculated, for any invoice line that has PRORATESERVICE=Y and no POLINENUM(service lines), an intermediate loaded cost has to be determined that is used to calculate the PRORATECOST. The calculation for LOADEDCOST checks the value of the ADDTAXINDCR flag to decide if the TAX value has to be added to the LINECOST to calculate the loaded cost, and accordingly calculates the loaded cost.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceTransForTaxes

        public void createInvoiceTransForTaxes()
                                        throws MXException,
                                               java.rmi.RemoteException
        This method creates the invoice transaction for taxes. These transactions are created as the last part of the invoice approval process. For every invoice line the tax1..5 are checked. If they are not null or zero, a new invoice transaction is created for every tax type based on the following conditions:
        1. If Pay Tax to Vendor is true and Include Tax is true, do not write transaction.
        2. If Pay Tax to Vendor is true and Include Tax is false, write transaction.
        3. If Pay Tax to Vendor is false and Include Tax is true, write transaction.
        4. If Pay Tax to Vendor is false and Include Tax is false, write transaction.
        Specified by:
        createInvoiceTransForTaxes in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • createInvoiceTransTotal

        public void createInvoiceTransTotal()
                                     throws MXException,
                                            java.rmi.RemoteException
        For the Invoice as a whole a single transaction of type TOTAL is written. This reflects the entire payment to be made to the vendor including taxes (if Pay Tax to Vendor is Y). This is in the invoice currency.
        Specified by:
        createInvoiceTransTotal in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • setRequiredInvoiceTransFields

        public void setRequiredInvoiceTransFields(MboRemote invoiceLine,
                                                  MboRemote newInvoiceTrans,
                                                  int j)
                                           throws MXException,
                                                  java.rmi.RemoteException
        This method is written just to reduce code and break up one long method. It sets the value of some of the required and non-required fields of InvoiceTrans Object. It is called everytime a new InvoiceTrans Tax transaction is created from the createInvoiceTransForTaxes method.
        Parameters:
        InvoiceLineRemote - The invoiceline for which this taxline is created.
        InvoiceTransRemote - The invoicetrans Mbo which is created for the invoiceline.
        j - The counter that is used to increment the tax subscript like tax1....tax5.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceForReceipt

        public MboRemote createInvoiceForReceipt(MboRemote receipt)
                                          throws MXException,
                                                 java.rmi.RemoteException
        Create InvoiceLine, InvoiceCost, InvoiceMatch for receipt. It will be called by matrectrans and servrectrans when pay on receiptis true or Y. The method returns an InvoiceLine MboRemote.
        Specified by:
        createInvoiceForReceipt in interface InvoiceRemote
        Parameters:
        receipt - Receipt which needs an invoice line to be created for.
        Returns:
        MboRemote The invoice line remote created.
        Throws:
        MXException
        java.rmi.RemoteException
      • canDelete

        public void canDelete()
                       throws MXException,
                              java.rmi.RemoteException
        This method is called by the Mbo's delete method. It checks if all the conditions are met to go ahead with the deletion of this record. Checks if the status of the invoice is ENTERED or WAPPR. Can only delete the invoice if the status of the invoice is ENTERED or WAPPR.
        Overrides:
        canDelete in class Mbo
        Throws:
        MXApplicationException - (invoice, DeleteIfEnteredOrWappr) Can only delete invoice with WAPPR or ENTERED status.
        MXException
        java.rmi.RemoteException
      • delete

        public void delete(long accessModifier)
                    throws MXException,
                           java.rmi.RemoteException
        This method deletes all the invoice lines connected to this invoice. The delete of the invoice lines deletes the related invoice match and invoice cost Mbos.
        Specified by:
        delete in interface MboRemote
        Overrides:
        delete in class Mbo
        Parameters:
        accessModifier -
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Mbo.delete(long)
      • setReadOnlyAfterApproval

        protected void setReadOnlyAfterApproval(boolean flag)
        Sets the read/only flags for fields in Invoice.
        Parameters:
        flag - Flag indicating if the fields are to be set to read/only or not.
      • getValidateOrder

        public java.lang.String[] getValidateOrder()
        Override the system method. This method is called by the framework and returns an array of fields whose order need to be maintained during the delayed validation. This sequence is for maximizing performance for API and yielding correct result. The sequence should be: ponum, documenttype, totaltax1, totaltax2, totaltax3, totaltax4, totaltax5, vendor, currencycode, originvoicenum, inclusive1, inclusive2, inclusive3, inclusive4, inclusive5, pretaxtotal, totalcost.
        Overrides:
        getValidateOrder in class Mbo
        Returns:
        String[] Array of invoice fields in the defined sequence.
      • getUninvoicedReceiptsInfo

        public Invoice.UninvoicedReceiptsInfo getUninvoicedReceiptsInfo()
        Return the object of UninvoicedReceiptInfo. There is only one instance of this object within an instance of Invoice. If the unInvoicedReceiptInfo is null, a new object will be instantiated.
        Returns:
        UninvoicedReceiptsInfo The object of UninvoicedReceiptInfo.
      • getAllUninvoicedReceipts

        public java.util.Vector getAllUninvoicedReceipts(java.lang.String poNum,
                                                         java.lang.String poLineNum,
                                                         int receiptType,
                                                         java.lang.String siteID,
                                                         boolean isNegativeLine,
                                                         java.lang.String receiptID)
                                                  throws MXException,
                                                         java.rmi.RemoteException
        This method finds a vector of uninvoiced receipts for the PO/POLine ordered by the receiving date. This method has to be called when the invoice has PO number on the header, otherwise, it will throw an exception. If the POLine number is specified as null in the parameter, all uninvoiced receipts for this PO will be found. The first time when this method is called for this invoice, it will first find a set of material or service receipts with the same PO number, POLine number and invoicenum=null. If invoicenum on a receipt is not null, it implies this receipt won't be considered again even if the receipt might not be fully matched. Check InvoiceMatch set for each receipt found, calculate its remaining uninvoiced qty or cost (if po-poline is by cost, use cost, otherwise use quantity) by subtracting the qty or cost of all invoice matches for this receipt from the original currencylinecost of the receipt. If the remaining quantity or cost is not 0, add it to the return vector. The information will remain in memory of this invoice waiting to be updated when a match is decided. The following calls to this method before save of this invoice will directly get information from the in-memory copy instead of going through the whole process again. The in-memory representation is an instance of class UninvoicedReceiptsInfo. It stores the information of the uninvoiced receipts of the PO indicated on this invoice.
        Parameters:
        poNum - PO number for this invoice line
        poLineNum - If specified, the method looks for uninvoiced receipts for this PO-POLine. If it is null, the method looks for all uninvoiced receipts for this PO.
        receipttype - The type of the receipt, it can be Invoice.MATERIAL or Invoice.SERVICE.
        siteID - The site identifier.
        Returns:
        Vector Vector of the uninvoiced receipts. It doesn't return the uninvoiced qty or cost of the receipts. These information can be obtained by calling getUninvoicedReceiptsInfo().
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        This vector should be ordered by receipt's transaction date.
      • getAllUninvoicedMatReceipts

        public java.util.Vector getAllUninvoicedMatReceipts(java.lang.String poNum,
                                                            java.lang.String poLineNum,
                                                            java.lang.String siteID,
                                                            boolean isNegativeLine,
                                                            java.lang.String receiptID)
                                                     throws MXException,
                                                            java.rmi.RemoteException
        Get all the uninvoiced material receipts.
        Specified by:
        getAllUninvoicedMatReceipts in interface InvoiceRemote
        Parameters:
        poNum - PO number for this invoice line
        poLineNum - The POLine number.
        siteID - The site identifier.
        Returns:
        Vector Vector of all uninvoiced material receipts.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #getAllUninvoicedReceipts(String, int)
      • getAllUninvoicedServReceipts

        public java.util.Vector getAllUninvoicedServReceipts(java.lang.String poNum,
                                                             java.lang.String poLineNum,
                                                             java.lang.String siteID,
                                                             boolean isNegativeLine,
                                                             java.lang.String receiptID)
                                                      throws MXException,
                                                             java.rmi.RemoteException
        Get all the uninvoiced service receipts.
        Specified by:
        getAllUninvoicedServReceipts in interface InvoiceRemote
        Parameters:
        poNum - PO number for this invoice line
        poLineNum - The POLine number.
        siteID - The site identifier.
        Returns:
        Vector Vector of all uninvoiced service receipts.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #getAllUninvoicedReceipts(String, int)
      • findMatch

        public java.util.Vector findMatch(boolean exactFirst,
                                          java.util.Vector uninvoicedReceipts,
                                          double minimumSigned,
                                          double maximumSigned,
                                          boolean byCost,
                                          boolean considerTax,
                                          boolean partialAllowed,
                                          InvoiceLineRemote invoiceLine,
                                          POLineRemote poline)
                                   throws MXException,
                                          java.rmi.RemoteException
        This method implements the algorithm to find one or multiple receipts from a list of receipts ordered by date in order to have their sum of line cost or qty fall within the range required. If the match is decided by quantity:
        1. If the sum of all uninvoiced receipts qty for this poline <= maximum value and >= minimum value, return them as the matched ones.
        2. Try to find the first receipt with the quantity <= maximum value and >= minimum value. If found return this receipt as the matched one.
        3. Starting from the earliest transaction date, include the receipts one by one until the sum of the receipts >= minimum value. If the sum <= maximum value, return these receipts as the matched ones. If sum >= maximum value and partialAllowed=true, keep deducting 1 from the quantity of the last receipt until the sum falls into the range. Return these receipts and the matched quantity.
        If the match is decided by cost: If considering tax, the cost of the receipt will be calculated as currencylinecost + tax.
        1. If the sum of all uninvoiced receipts cost for this poline <= maximum value and >= minimum value, return them as the matched ones.
        2. Try to find the first receipt with the cost <= maximum value and >= minimum value. If found return this receipt as the matched one.
        3. Starting from the earliest transaction date, include the receipts one by one until the sum of the receipts >= minimum value. If the sum <= maximum value, return these receipts as the matched ones. If sum >= maximum value and partialAllowed=ture, use partial cost of the last receipt until it falls into the range. Return these receipts and the matched cost.
        Parameters:
        boolean - True if a receipt of exact to be matched quantity has to be taken if exists. This needs to be false if it is for the manual matching.
        Vector - A vector of uninvoiceReceipts with their uninvoiced cost and qty. The match will be conducted from those receipts.They have to be ordered by their transaction date.
        minimum - The minimum of the quantity or cost the matched receipts have to have. If it is a quantity, it should be in issue unit. The minimum should be the minimum of the absolute value if it is negative. For example, between -5 and -10, -5 should be assigned to this parameter.
        maximum - The maximum of the quantity or cost the matched receipts have to have. If minimum = maximum, an exact match has to be found. If it is a quantity, it should be in issue unit. The maximum should be the maximum of the absolute value if it is negative. For example, between -5 and -10, -10 should be assigned to this parameter.
        byCost - If the match is based on cost or quantity.
        considerTax - If considertax is true, when byCost=true, the tax of the receipts will be contributed to the total cost. This flag is useful only when byCost=true. It is currently not implemented to consider this flag, since this is only to be useful by trial match. If trial match is decided to be dropped, we'll remove this parameter. If not, the function will be modified to consider this parameter when trial match is being implemented.
        partialAllowed - Whether a proportion of receipt can be part of the match to the invoice line.
        invoiceLine - Invoice line to be matched. It is null when invoice line is not involved such as during trial match.
        Returns:
        Vector A vector containing MatchResult, which is receiptRemote and the matched qty or matched cost. It returns null, if no match is found.
        Throws:
        MXException
        java.rmi.RemoteException
      • findMatch

        public java.util.Vector findMatch(boolean exactFirst,
                                          java.util.Vector uninvoicedReceipts,
                                          double value,
                                          boolean byCost,
                                          InvoiceLineRemote invoiceLine,
                                          POLineRemote poline)
                                   throws MXException,
                                          java.rmi.RemoteException
        A simplified format of findMatch() method. It is meant to be used by the invoice matching for each individual invoice line.
        Specified by:
        findMatch in interface InvoiceRemote
        Parameters:
        boolean - True if a receipt of exact to be matched quantity has to be taken if exists. This needs to be false if it is for the manual matching.
        Vector - A vector of uninvoiceReceipts with their uninvoiced cost and qty. The match will be conducted from those receipts.They have to be ordered by their transaction date.
        value - The quantity or cost the matched receipts have to have. If it is a quantity, it should be in issue unit.
        byCost - If the match is based on cost or quantity.
        invoiceLine - Invoice line to be matched. It is null when invoice line is not involved such as during trial match.
        Returns:
        Vector A vector containing MatchResult, which is receiptRemote and the matched qty or matched cost. It returns null, if no match is found.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        findMatch(Vector, Vector, double, double, boolean, boolean, boolean, InvoiceLineRemote)
      • confirmMatch

        public void confirmMatch(MboRemote invoiceLine,
                                 java.util.Vector matchReceipts)
                          throws MXException,
                                 java.rmi.RemoteException
        This method confirms that a previously found match by findMatch() is being confirmed. The result of the match will update the in-memory representation of the uninvoiced receipts information. From now on, and future match operation will not consider the qty or cost of the receipt which are already confirmed. It calls method update() of inner class UninvoicedReceiptInfo. Don't try to perform invoice match between the calls of findMatch() and confirmMatch() because in between the unInvoicedReceiptsInfo hasn't been updated. We don't want to combine these two calls together because there might be possibilities that a found match will not be confirmed, such as during a trial match. Within a single invoice instance, it will not be possible to have a match before the previous match is confirmed or ignored.
        Specified by:
        confirmMatch in interface InvoiceRemote
        Parameters:
        invoiceLine - The invoice line for which the invoice match is being confirmed.
        matchReceipt - A vector of the receipt and the matched qty or cost needs to be updated.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceTransAfterAppr

        public void createInvoiceTransAfterAppr(MboRemote invoice,
                                                double currencyVariance,
                                                double priceVariance)
                                         throws MXException,
                                                java.rmi.RemoteException
        This method is to be used to create invoice variance transactions after approval. Mainly to be used by the ERP group. If you are calling this method in the same transaction in which the approval was done just pass in the invoice remote along with the variances. Can only be done if the invoice status is approved.
        Specified by:
        createInvoiceTransAfterAppr in interface InvoiceRemote
        Parameters:
        invoice - The MboRemote of the invoice.
        currencyVariance - The currency variance.
        priceVariance - The price variance.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceTransAfterAppr

        public void createInvoiceTransAfterAppr(java.lang.String invoicenum,
                                                double currencyVariance,
                                                double priceVariance)
                                         throws MXException,
                                                java.rmi.RemoteException
        This method is to be used to create invoice variance transactions after approval. Mainly to be used by the ERP group. If you are not calling this method in the same transaction in which the approval was done pass in the invoicenum along with the variances. Can only be done if the invoice status is approved.
        Specified by:
        createInvoiceTransAfterAppr in interface InvoiceRemote
        Parameters:
        invoice - The invoicenum of the invoice.
        currencyVariance - The currency variance.
        priceVariance - The price variance.
        Throws:
        MXException
        java.rmi.RemoteException
      • duplicate

        public MboRemote duplicate()
                            throws MXException,
                                   java.rmi.RemoteException
        Duplicates an Invoice record. Also duplicates the InvoiceLine, InvoiceCost and InvoiceStatus for this Invoice, and the related Linked Documents(DocLinks).
        Specified by:
        duplicate in interface MboRemote
        Overrides:
        duplicate in class Mbo
        Returns:
        MboRemote The newly created Invoice.
        Throws:
        MXException
        java.rmi.RemoteException
      • skipCopyField

        protected boolean skipCopyField(MboValueInfo mvi)
                                 throws MXException,
                                        java.rmi.RemoteException
        Overrides the skipCopyField() in the Mbo. Since this method takes the MboValueInfo as its parameter just check to see if this field needs to be copied or skipped by using the data from the static HashSet. If this field does not need to be copied return true. The following are the Invoice fields will be skipped without being copied to the newly duplicated Invoice:
        1. invoicenum
        2. status
        3. changeby
        4. changedate
        5. enterby
        6. enterdate
        7. checkcode
        8. checknum
        9. approvalnum
        10. exchangerate
        11. exchangerate2
        12. exchangedate
        13. duedate
        14. paid
        15. paiddate
        16. statusdate
        17. discount
        18. discountdate
        19. historyflag
        20. sourcesysid
        21. ownersysid
        22. externalrefid
        23. sendersysid
        24. orgid
        Overrides:
        skipCopyField in class Mbo
        Parameters:
        mvi - The MboValueInfo object of the MboValue that needs to be copied.
        Returns:
        true If the field does not need to be copied return true, in all other cases return false.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Invoice.loadSkipFieldCopyHashSet()
      • copyPOLineToInvoiceLine

        public MboSetRemote copyPOLineToInvoiceLine(MboSetRemote poLineSet)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Create the invoice lines based on the passed in PO Line set and copy over the related info. This method will be used by the GUI for the Copy PO Line action.
        Specified by:
        copyPOLineToInvoiceLine in interface InvoiceRemote
        Parameters:
        poLineSet - The PO Line set from which the invoice lines are to be created.
        Returns:
        MboSetRemote The newly created invoice line set.
        Throws:
        MXException
        java.rmi.RemoteException
      • changeStatus

        public void changeStatus(java.lang.String status,
                                 java.util.Date date,
                                 java.lang.String memo,
                                 long accessModifier)
                          throws MXException,
                                 java.rmi.RemoteException
        This method is overridden to add a wrapper to exceptions thrown during change status and to write warnings whether or not the status change is successful
        Specified by:
        changeStatus in interface StatefulMboRemote
        Overrides:
        changeStatus in class StatefulMbo
        Parameters:
        status - The new desired status. This is the translated status (that is, the status code as it would have been entered by a user, or valuelist.value), not the internal status value (valuelist.maxvalue).
        date - The effective date of the new status (java.util.Date). If null the current date/time is used.
        memo - A string briefly describing the circumstances of the change. The memo can be null.
        accessModifier - A value of NOACCESSCHECK will cause the method not to call canChangeStatus. Callers using this flag are responsible for ensuring that they are attempting a valid status change.
        Throws:
        MXException - Thrown if there is a problem.
        java.rmi.RemoteException
        See Also:
        StatefulMbo.canChangeStatus(String)
      • changeStatus

        public void changeStatus(java.lang.String status,
                                 java.util.Date date,
                                 java.lang.String memo,
                                 boolean autoClosePo)
                          throws MXException,
                                 java.rmi.RemoteException
        This method is to be called by the UI change status page. If the user wants the PO to be closed, the PO object is asked to close the PO after doing all the necessary checks.
        Specified by:
        changeStatus in interface InvoiceRemote
        Parameters:
        status - The desired status.
        date - The current date.
        memo - Any notes by the user.
        autoClosePO - Indicates if the PO is to be closed.
        Throws:
        MXException
        java.rmi.RemoteException
      • changeStatus

        public void changeStatus(java.lang.String status,
                                 java.util.Date date,
                                 java.lang.String memo)
                          throws MXException,
                                 java.rmi.RemoteException
        This method is to be called internally when the invoice status is to be changed. Mainly it will be used for approving invoice. We have to check the maxvar AUTOCLOSEPO to check if the PO is to be closed.
        Specified by:
        changeStatus in interface StatefulMboRemote
        Overrides:
        changeStatus in class StatefulMbo
        Parameters:
        status - The desired status.
        date - The current date.
        memo - Any notes by the user.
        Throws:
        MXException - Thrown if there is a problem, or the status cannot be changed, as determined by canChangeStatus(String).
        java.rmi.RemoteException
        See Also:
        StatefulMbo.changeStatus(String,java.util.Date,String,long)
      • calculateUnInvoicedTotal

        public double calculateUnInvoicedTotal()
                                        throws MXException,
                                               java.rmi.RemoteException
        This method calculates the uninvoiced total cost for a PO used on an invoice. The formula is uninvoicedtotal = PO total -(invoice lines cost + inclusive taxes). The invoice lines cost is equal to the total of all the invoicelines for this PO. If there is no PO entered for this invoice no need to calculate the uninvoiced cost.
        Throws:
        MXException
        java.rmi.RemoteException
      • copyReceiptToInvoiceLine

        public MboSetRemote copyReceiptToInvoiceLine(MboSetRemote receiptSet)
                                              throws MXException,
                                                     java.rmi.RemoteException
        Create the invoice lines based on the passed in receipts set and copy over the related info. This method will be used by the GUI for the Copy PO Line action, when Materials or Service tab is selected.
        Specified by:
        copyReceiptToInvoiceLine in interface InvoiceRemote
        Parameters:
        receiptSet - The receipt set from which the invoice lines are to be created.
        Returns:
        MboSetRemote The newly created invoice line set.
        Throws:
        MXException
        java.rmi.RemoteException
      • canAllocateService

        public void canAllocateService()
                                throws MXException,
                                       java.rmi.RemoteException
        Check if allocation service action can be done. Throw exception if the to be allocated lines don't exist or the lines to accept allocated services don't exist. The invoice and the invoiceline has to be already saved at this moment. Cannot allocate a reversed invoice or allocate a invoice with the reversed invoice.
        Specified by:
        canAllocateService in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Invoice.canAllocateService()
      • getAllocatePrepSets

        public InvoiceLineSetRemote[] getAllocatePrepSets(InvoiceLineSetRemote toBeAllocated,
                                                          InvoiceLineSetRemote acceptingLines)
                                                   throws MXException,
                                                          java.rmi.RemoteException
        According to the two mbo set passed in and what are selected in those two sets, this method returns a array of two new sets for the GUI to display. Those sets are contains the to be allocated lines and those ready to accept the allocation.
        Specified by:
        getAllocatePrepSets in interface InvoiceRemote
        Parameters:
        toBeAllocated - InvoiceLine set which should be obtained by relationship PRORATEYLINES.
        acceptingLines - InvoiceLine set which should be obtained by relationship PRORATENLINES.
        Returns:
        An array of two InvoiceLine Sets, which are the sets that the allocate service will eventually happen. The first element is the to be allocated set, and the second element is the set of lines which will accept the allocation.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#getAllocatePrepSets()
      • validateAndCompleteAllocation

        public void validateAndCompleteAllocation(InvoiceLineSetRemote toBeAllocated,
                                                  InvoiceLineSetRemote acceptingLines)
                                           throws MXException,
                                                  java.rmi.RemoteException
        Validate the allocation, if the total to be allocated is different than the total being allocated, throw an exception. If it is valid, it completes the allocation by setting the prorated flag, proratecost and loaded cost of the lines in the to be allocated set if this hasn't been done. This is because the allocation process can totally be manual through the GUI and the to be allocated lines won't be updated until this moment.
        Specified by:
        validateAndCompleteAllocation in interface InvoiceRemote
        Parameters:
        toBeAllocated - The set contains all the lines which will be allocated.
        acceptingLines - The set contains all the line will be accepting allocation.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#validateAllocation()
      • allocateServices

        public void allocateServices(InvoiceLineSetRemote toBeAllocated,
                                     InvoiceLineSetRemote acceptingLines)
                              throws MXException,
                                     java.rmi.RemoteException
        Allocated the amount of services as specified in toBeAllocated to all the lines in the acceptingSet proportional to the linecosts of the lines in the acceptingSet.
        Specified by:
        allocateServices in interface InvoiceRemote
        Parameters:
        toBeAllocated - The set contains all the lines which will be allocated.
        acceptingLines - The set contains all the line will be accepting allocation.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#allocateServices()
      • cancelAllocateService

        public void cancelAllocateService()
                                   throws MXException,
                                          java.rmi.RemoteException
        Cancel the allocation service action. This method is called by the GUI when the allocate service action was performed but user chooses to cancel before save. The invoice line information will be back to what they were before the allocate service action.
        Specified by:
        cancelAllocateService in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Invoice.cancelAllocateService()
      • resetTotalAllocated

        public void resetTotalAllocated(InvoiceLineSetRemote lineSet)
                                 throws MXException,
                                        java.rmi.RemoteException
        Re-calculate the totalallocated fields on invoice based on the passed in invoiceline set. This is called by the field action of proratecost field.
        Specified by:
        resetTotalAllocated in interface InvoiceRemote
        Parameters:
        lineSet - should be the set of lines receiving allocated services. When this method is being called, the previous allocation should have been cleared, and the lineset contains all the records which are accepting allocated services in this allocate service process.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#resetTotalAllocated()
      • getPOReference

        public MboRemote getPOReference()
      • getCopyPOLineSet

        public MboSetRemote getCopyPOLineSet(java.lang.String tbName)
                                      throws MXException,
                                             java.rmi.RemoteException
        This method is to be called by the UI code to get the appropriate poline, material or service sets to be displayed by the Copy PO Line page. If there is a ponum on the invoice header use it to get the polines or receipts. If there is a vendor on the invoice header but no ponum, get all the polines or receipts for all the POs with this vendor or any of its children. The POs referenced should not be cancelled or waiting for approval. If the the invoice is of type CREDIT, only the receipts which have negative quantity or costs will be displayed. For types INVOICE and DEBIT, only positive receipts will be dispalyed.
        Specified by:
        getCopyPOLineSet in interface InvoiceRemote
        Parameters:
        String - The UI should pass in the tablename which basically should represent the tab from where it is called i.e. POLINE, MATRECTRANS or SERVRECTRANS.
        Returns:
        MboSetRemote A set of the polines or receipts.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#getCopyPOLineSet()
      • save

        public void save()
                  throws MXException,
                         java.rmi.RemoteException
        Override the super class save. We have to do the invoice matching on save. The invoice matching will not be done if the invoice is approved or paid.
        Overrides:
        save in class StatefulMbo
        Throws:
        MXException
        java.rmi.RemoteException
      • getWOReference

        public MboRemote getWOReference(java.lang.String wonum)
                                 throws MXException,
                                        java.rmi.RemoteException
        This method is used to get the workorder reference mbo which will be updated by the receipt. It is being done this way to avoid updating different references of the same workorder.
        Throws:
        MXException
        java.rmi.RemoteException
      • getWOReference

        public MboRemote getWOReference(java.lang.String wonum,
                                        java.lang.String siteID)
                                 throws MXException,
                                        java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • setTaxGLs

        public void setTaxGLs(java.lang.String taxCode,
                              int typeCode)
                       throws MXException,
                              java.rmi.RemoteException
        Set the tax GL accounts based on the type of the taxcode set on the invoice line. The following rules apply.
        1. If Pay Tax to Vendor is true and the tax.inclusivegl is not null, set invoice.taxgl(1-5) to tax.inclusivegl.
        2. If Pay Tax to Vendor is true and the tax.inclusivegl is null, set invoice.taxgl(1-5) to taxtype.inclusivegl.
        3. If Pay Tax to Vendor is false and the tax.exclusivegl is not null, set invoice.taxgl(1-5) to tax.exclusivegl.
        4. If Pay Tax to Vendor is false and the tax.exclusivegl is null, set invoice.taxgl(1-5) to taxtype.exclusivegl.
        Throws:
        MXException
        java.rmi.RemoteException
      • copyTerms

        public void copyTerms(MboSetRemote termsSet)
                       throws MXException,
                              java.rmi.RemoteException
        This method will copy the selected terms to the set calling Mbo's corresponding Terms. It will be used for selecting Terms to POTerm, PRTerm or ContractTerm.
        Specified by:
        copyTerms in interface InvoiceRemote
        Parameters:
        termsSet - the pass in Term Set.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#copyTerms()
      • createInvoiceForPurchSched

        public MboRemote createInvoiceForPurchSched(MboRemote poLine,
                                                    MboRemote scheduleLine,
                                                    MboRemote receipt)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Create invoice lines and invoice costs for invoice created through payment schedule. This will only happen during PO approval or receipt creation depending upon the setup. No invoice matches are created for invoices created from payment schedules.
        Specified by:
        createInvoiceForPurchSched in interface InvoiceRemote
        Parameters:
        MboRemote - poLine
        MboRemote - scheduleLine
        MboRemote - receipt
        Returns:
        MboRemote invoiceLine
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#createInvoiceForPurchSched()
      • createInvoiceForLabTrans

        public MboRemote createInvoiceForLabTrans(MboRemote labTrans,
                                                  double quantity,
                                                  double lineCost,
                                                  boolean lineByLine)
                                           throws MXException,
                                                  java.rmi.RemoteException
        Create invoice lines and invoice costs for invoice created through labor transactions. The invoice lines will be created base on consolidation by work order or line by line. No invoice matches will be created for these invoice lines.
        Specified by:
        createInvoiceForLabTrans in interface InvoiceRemote
        Parameters:
        MboRemote - labTrans
        double - quantity
        double - lineCost
        boolean - lineByLine
        Returns:
        MboRemote invoiceLine
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#createInvoiceForLabTrans()
      • createInvoiceForLeaseSched

        public MboRemote createInvoiceForLeaseSched(MboRemote schedule,
                                                    double quantity,
                                                    double lineCost,
                                                    boolean singleLine)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Create invoice lines and invoice costs for invoice created through lease contracct payment schedule. No invoice matches will be created for these invoice lines.
        Specified by:
        createInvoiceForLeaseSched in interface InvoiceRemote
        Parameters:
        MboRemote - schedule
        double - quantity
        double - lineCost
        boolean - singleLine
        Returns:
        MboRemote invoiceLine
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#createInvoiceForLeaseSched()
      • copyFromContract

        public void copyFromContract(MboRemote contractRemote)
                              throws MXException,
                                     java.rmi.RemoteException
        Copy contract info to Invoice header. 1) Copy contract vendor related info to Invoice vendor related info (paymentterms and inclusive1-5). 2) Copy Contracts Terms and Conditions to Invoice.
        Throws:
        MXException
        java.rmi.RemoteException
      • nullVendor

        public void nullVendor()
                        throws MXException,
                               java.rmi.RemoteException
        Throws an exception if the vendor on the invoice header is null.
        Specified by:
        nullVendor in interface InvoiceRemote
        Throws:
        MXApplicationException("invoice", - "VendorIsNull");
        MXException
        java.rmi.RemoteException
        See Also:
        Invoice.nullVendor()
      • createInvoiceForWarrSched

        public MboRemote createInvoiceForWarrSched(MboRemote schedule,
                                                   double quantity,
                                                   double lineCost)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Create invoice lines and invoice costs for invoice created through warranty contract payment schedule. No invoice matches will be created for these invoice lines.
        Specified by:
        createInvoiceForWarrSched in interface InvoiceRemote
        Parameters:
        MboRemote - schedule
        double - quantity
        double - lineCost
        Returns:
        MboRemote invoiceLine
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice.Invoice#createInvoiceForWarrSched()
      • getMboSet

        public MboSetRemote getMboSet(java.lang.String name)
                               throws MXException,
                                      java.rmi.RemoteException
        Over-ride the getMboSet method to return a different MboSet if the relationship name is INVOICEPOTERM. Note - The INVOICEPOTERM should not be used anywhere else.
        Specified by:
        getMboSet in interface MboRemote
        Overrides:
        getMboSet in class Mbo
        Parameters:
        name - The relationship provided to retrieve a related mboSet, usually using foreign keys. For example, "psdi.app.workorder.WOSetRemote.ASSET" is a relationship for the work order object to access the asset Set where "workorder.assetnum=asset.assetnum". The relationship can also be chained. Such as ASSET.ASSETSTATUS.
        Returns:
        The returned related set specified through the relationship.
        Throws:
        MXException - "A relationship called {0} does not exist for the {1} business object" exception will be thrown if the relationship was not found. "Unknown Object" exception will be thrown if the database object can not be found through the relationship.
        java.rmi.RemoteException
        See Also:
        Mbo.getMboSet(String)
      • checkAndClearAllocatedLines

        public void checkAndClearAllocatedLines()
                                         throws MXException,
                                                java.rmi.RemoteException
        Called by the UI to caheck if allocation has been done on this invoice. Based on the user input either the allocation is undone or and the Allocate Service dialog is shown, or we stop the process.
        Specified by:
        checkAndClearAllocatedLines in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • canCopyPOLines

        public void canCopyPOLines()
                            throws MXException,
                                   java.rmi.RemoteException
        Checks to see if there is a contract reference on the invoice. If there is a contract reference on the invoice, the Copy POLines button cannot be clicked.
        Specified by:
        canCopyPOLines in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • getPOHash

        public java.util.Hashtable getPOHash()
        Used by the poClose method to get the correct po instance for updating from the receipt as well as the po status handler.
      • setPOHash

        public void setPOHash(PORemote thePO)
                       throws MXException,
                              java.rmi.RemoteException
        Used while creating receipts from invoice to keep track of and use the correct po instance which will be later used while closing the po.
        Throws:
        MXException
        java.rmi.RemoteException
      • isConditionEnabled

        public void isConditionEnabled(MboSetRemote poLineSet,
                                       boolean copyFromPOLineTab)
                                throws MXException,
                                       java.rmi.RemoteException
        This method checks if the poline that is being copied has a condition enabled item. This is only applicable for item lines and will only be called whyen the user is copying the PO line from the PO Lines tab of the Copy PO Lines dialog in Invoice app. If the po line is condition enabled the user is asked to use the Materials tab.
        Specified by:
        isConditionEnabled in interface InvoiceRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • smartFindByObjectName

        public MboSetRemote smartFindByObjectName(java.lang.String sourceObj,
                                                  java.lang.String targetAttrName,
                                                  java.lang.String value,
                                                  boolean exact)
                                           throws MXException,
                                                  java.rmi.RemoteException
        Find a set of records of the object of the specified the application by the specified attribute and values of the current record.
        Specified by:
        smartFindByObjectName in interface MboRemote
        Overrides:
        smartFindByObjectName in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.mbo.Mbo#smartFindByObjectName()
      • createReverseInvoice

        public void createReverseInvoice(java.lang.String invoiceNum,
                                         java.lang.String description,
                                         java.lang.String revReason,
                                         java.util.Date glPostdate,
                                         java.lang.String status)
                                  throws MXException,
                                         java.rmi.RemoteException
        Create Reverse Invoice
        Specified by:
        createReverseInvoice in interface InvoiceRemote
        Parameters:
        invoiceNum - Reverse invoice number
        description - Reverse invoice number description
        revReason - Reason for reverse
        glPostdate - GL post date of the reverse invoice
        status - status of the reverse invoice
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • defineSysCode

        public long[] defineSysCode()
                             throws MXException,
                                    java.rmi.RemoteException
        Return long array for InvoiceSysCode.TOTALTAX1 to TOTALTAXN
        Returns:
        long array for InvoiceSysCode.TOTALTAX1 to TOTALTAXN
        Throws:
        MXException
        java.rmi.RemoteException
      • getSysCode

        public long getSysCode(int i)
                        throws MXException,
                               java.rmi.RemoteException
        Return sysCode based on the array position.
        Parameters:
        integer - - array position
        Returns:
        long sysCode based on array position.
        Throws:
        MXException
        java.rmi.RemoteException
      • isSyscodeSet

        public boolean isSyscodeSet()
                             throws MXException,
                                    java.rmi.RemoteException
        Check if fields are set by external user.
        Returns:
        boolean True if fields as indicated in the parameter is set by external user. Fields are TOTALCOST, PRETAXTOTAL, TOTALTAX1 to TOTALTAXN. They are specified in InvoiceSysCode.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        #InvoiceSysCode
      • setInvoiceMatchReversed

        public void setInvoiceMatchReversed()
                                     throws MXException,
                                            java.rmi.RemoteException
        A utility method called by the status handler when setting the invoice status to REVERSED. All the related invoice match will have their reversed flag set to true. This will help in matching the receipts again for a new invoice.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceLineForCons

        public void createInvoiceLineForCons(java.util.ArrayList consTransByVendorList)
                                      throws MXException,
                                             java.rmi.RemoteException
        Creates invoice lines for this invoice based on the selected mbos passed in the ArrayList. This method is called by frequeny and consumption based invoice generation.
        Specified by:
        createInvoiceLineForCons in interface InvoiceRemote
        Parameters:
        consTransByVendorList -
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        psdi.app.invoice
      • updateConsTransInvoiceNum

        public void updateConsTransInvoiceNum(boolean clearInvoiceNum)
                                       throws MXException,
                                              java.rmi.RemoteException
        Update the transaction that created this invoice/invoice line with the invoice number. This is done as we don't want to use these transactions to again create invoices. In case we cancel or delete the invoice, we should removes the invoice number from the related transactions.
        Parameters:
        clearInvoiceNum - Boolean to indicate if we need to clear invoice number if true
        Throws:
        MXException
        java.rmi.RemoteException
      • createVarTransForConInvoice

        public void createVarTransForConInvoice()
                                         throws MXException,
                                                java.rmi.RemoteException
        If this is a consignment invoice we have see if there is a variance and create variance transactions
        Throws:
        MXException
        java.rmi.RemoteException
      • isOrgInvoiceSchedType

        public boolean isOrgInvoiceSchedType()
                                      throws MXException,
                                             java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • toPostDontCheckCompleteFlag

        public boolean toPostDontCheckCompleteFlag(MboRemote thePO,
                                                   MboRemote invoiceLine,
                                                   MboRemote theReceipt)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Check if all other polines for which receipts have been completed before posting the message po.DONTCHECKCOMPLETEFLAG on the bulletin board. If there are any partial receipts on other polines, should not post
        Parameters:
        thePO -
        invoiceLine -
        theReceipt -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • taxWithinTolerance

        public boolean taxWithinTolerance(double lineTaxTotal,
                                          double totalTax)
                                   throws java.rmi.RemoteException,
                                          MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • createDepreciation

        public void createDepreciation(boolean recalculationPoint,
                                       java.util.List warnings)
                                throws MXException,
                                       java.io.IOException
        Throws:
        MXException
        java.io.IOException
      • checkDepreciation

        public boolean checkDepreciation()
                                  throws MXException,
                                         java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException