psdi.app.invoice

Class InvoiceLine

  • java.lang.Object
  • All Implemented Interfaces:
    java.rmi.Remote, InvoiceLineRemote, MboConstants, MboRemote, MaxRemoteProxy


    public class InvoiceLine
    extends Mbo
    implements InvoiceLineRemote
    Mbo object to represent InvoiceLine. InvoiceLine stores line items for an invoice. It contains the total value and quantity that is associated to that line. An invoice cannot be approved without an invoice line. Invoice line cannot be modifed if the invoice is approved. Each invoice line should have at least one invoice cost line.

    See Invoice Package description.

    The key attributes for this object are InvoiceNum and InvoiceLineNum.

    The attributes in this object are as follows:

    Attribute NameAttribute Description
    ContractRefNumRead-only field containing the reference number of the contract.
    DescriptionDescription of the item.
    ConversionThe value used to convert the order unit to the issue unit, and vice versa.
    EnterByThe name or user ID of the person who created the line item.
    EnterDateDate and time the line item was created.
    InvoiceLineNumUnique system generated invoice line item number.
    InvoiceNumIdentifier of the invoice.
    InvoiceQtyNumber of items invoiced on this line.
    InvoiceUnitStandard unit by which the item is ordered, taken from the PO line.
    ItemNumItem number, displayed from the corresponding Purchase Order (PO) line. Foreign key to FldInventoryItemnum.
    ItemSetIDItem Set Identifier. *
    LDkeyLong Description Key.
    LineCostCost of the line item, calculated as Invoice Quantity * Unit Cost.
    LineCost2Line cost in base currency 2.
    LineTypeThe type of Invoice Line. Possible values include ITEM, MATERIAL, SERVICE or EXTERNAL.
    LoadedCostTotal cost of the line item calculated as: Line Cost + Tax + Standard Service.
    OrgIDOrganization Identifier.
    POLineNumLine item on the Purchase Order (PO) that this invoice line refers to.
    PONumPurchase Order (PO) that the line item is from. Foreign key to PO.
    ProrateCostAmount of standard service costs loaded on the line item.
    ProratedYes/No field indicating whether the line item has been prorated (allocated).
    ProrateServiceYes/No field indicating whether the cost of the standard services should be prorated (loaded) to this line item's cost.
    ReceiptReqdYes/No field indicating whether invoice matching is required.
    SiteIDSite Identifier.
    Tax1 - Tax5Amount of tax for taxcode of type 1 thru 5, payable for the line item.
    Tax1Code - Tax5CodeThe taxcode of type 1 thru 5, used to calculate the value of TAX1 thru TAX5 fields.
    UnitCostCost per unit of the item.
    VendorSupplier of the invoice. Foreign key to Company.
    InvoiceLin1 - InvoiceLin9Extra fields.
    • Field Detail

      • poToleranceCalculated

        public boolean poToleranceCalculated
      • curVarTotal

        public double curVarTotal
      • priceVarTotal

        public double priceVarTotal
      • taxDiffOnly

        public boolean taxDiffOnly
      • matchForApproval

        protected boolean matchForApproval
    • Constructor Detail

      • InvoiceLine

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

      • init

        public void init()
                  throws MXException
        Initialzation rountine. Set some fields to read/only when initialized.
        Overrides:
        init in class Mbo
        Throws:
        MXException
      • add

        public void add()
                 throws MXException,
                        java.rmi.RemoteException
        This is called when a new invoice line is added by invoice It sets the default field values and access flags of the invoice line. At the same time when the invoice line is added to an invoice, a new invoice cost(InvoiceCost) for this line is also added. The table below shows the default values for each of the attributes listed.
        Attribute NameAttribute Value
        enterbyCurrent username
        enterdateCurrent date
        invoicelinenumAdd one to the existing maximum value
        invoicenumOwner Invoice's invoicenum
        linecost0.0(Zero)
        linecost20.0(Zero)
        loadedcost0.0(Zero)
        ponumOwner Invoice's ponum(if any)
        proratedNo
        prorateserviceNo
        receiptreqdNo
        LinetypeService
        tax1..50.0(Zero)
        vendorOwner Invoice's vendor
        Specified by:
        add in interface MboRemote
        Overrides:
        add in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • modify

        public void modify()
                    throws MXException,
                           java.rmi.RemoteException
        This is called whenever a change is made to the attributes of invoice line. When any field related to invoice line is changed, the owner invoice's changedate/changeby is updated.
        Overrides:
        modify in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • setEditibilityFlags

        protected void setEditibilityFlags()
                                    throws MXException,
                                           java.rmi.RemoteException
        Set the read-only flags for fields where it changes.
        Throws:
        MXException
        java.rmi.RemoteException
      • canDelete

        public void canDelete()
                       throws MXException,
                              java.rmi.RemoteException
        Invoice line can only be deleted if the owner invoice status is ENTERED or WAPPR equivalent. Also cannot delete invoice line if allocation has been done.
        Overrides:
        canDelete in class Mbo
        Throws:
        MXApplicationException - (invoice, CannotDeleteLine) Cannot delete invoice line if invoice status is not ENTERED or WAPPR equivalent.
        MXApplicationException - (invoice, CannotDeleteAllocatedLines) Cannot delete invoice line if allocation has been done.
        MXException
        java.rmi.RemoteException
      • delete

        public void delete(long accessModifier)
                    throws MXException,
                           java.rmi.RemoteException
        Delete the invoice line record. It will also delete associated invoice match and invoice cost records. If all the invoice lines are deleted, the syscode to indicate if there are invoice lines is cleared. Also the total tax 1..5,the pretaxtotal and uninvoicedtotal is re-calculated.
        Specified by:
        delete in interface MboRemote
        Overrides:
        delete in class Mbo
        Parameters:
        accessModifier -
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Mbo.delete(long)
      • getPOToInvCur

        public double getPOToInvCur()
                             throws MXException,
                                    java.rmi.RemoteException
        Obtain the exchangerate from po's currency to invoice's currency. Use three-step method to find exchange rate.
        Specified by:
        getPOToInvCur in interface InvoiceLineRemote
        Returns:
        double The exchange rate from PO to Invoice currency.
        Throws:
        MXApplicationException - (invoice, POMissing) PO not found.
        MXApplicationException - (invoice, ExchangeRateNotFound) Exchangerate not found.
        MXException
        java.rmi.RemoteException
      • recalculatePreTaxTotalWhenDelete

        public void recalculatePreTaxTotalWhenDelete()
                                              throws MXException,
                                                     java.rmi.RemoteException
        This method re-calculates pretaxtotal. It is called during delete of an invoice line. When the syscode indicates the pretaxtotal is not set by the user, the pretaxtotal will be re-calculated by subtracting the linecost of the line being deleted from the original pretaxtotal on the invoice header.
        Throws:
        MXException
        java.rmi.RemoteException
      • appValidate

        public void appValidate()
                         throws MXException,
                                java.rmi.RemoteException
        Pre-save validation method. The invoice cost this invoice line has to be valid before it can be saved. The invoice cost's quantity, cost, percentage have to be consistent with the corresponding invoice line.
        Overrides:
        appValidate in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • validateInvoiceMatch

        public void validateInvoiceMatch()
                                  throws MXException,
                                         java.rmi.RemoteException
        Called by appValidate() to validate the invoice match lines associated with this invoice line. The matched receipts have to exist. The total quantity of the matched receipt cannot exceeds the total received receipts of PO-POLine.
        Throws:
        MXApplicationException - (invoice, InvoiceMatchInvalid) Total of invoice match quantity not equal to that of invoice line.
        MXApplicationException - (invoice, InvoiceMatchExceedsReceipt) Invoice match quantity should be equal to the receipt quantity.
        MXException
        java.rmi.RemoteException
      • copyPOLine

        public void copyPOLine()
                        throws MXException,
                               java.rmi.RemoteException
        Copy the poline fields. It is called by the field validation of invoice line's polinenum. It sets some default fields on the invoice line according to the po-poline combo. Fields being set are itemnum, itemsetid, description, conversion, invoiceunit, unitcost, receiptreqd, tax1..5code, service, loadedcost, proratecost, prorateservice, contractrefnum related fields, invoicelin1..9, invoiceqty, linecost.
        Specified by:
        copyPOLine in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • clearPOLine

        public void clearPOLine()
                         throws MXException,
                                java.rmi.RemoteException
        Clear the fields copied from poline on deleting the polinenum. The fields are set to their defaults value where ever applicable.
        Specified by:
        clearPOLine in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • validateCurrency

        public void validateCurrency(java.lang.String invoiceCurrency)
                              throws MXException,
                                     java.rmi.RemoteException
        Called by invoice's currencyValidation() before approval. On an invoiceline, the po currency should be able to convert to invoice currency and base currency. If exchange rate is not found, exception will be thrown. The currency exchange rates among po's currency, invoice's currency, and base currency are obtained and stored for future use. This method is only called if there is no PO on invoice header.
        Specified by:
        validateCurrency in interface InvoiceLineRemote
        Parameters:
        invoiceCurrency - Invoice currency on the invoice header.
        Throws:
        MXApplicationException - (invoice, ExchangeRateNotFound) Exchange rate not found.
        MXException
        java.rmi.RemoteException
      • validateInvoiceMatchForApproval

        public void validateInvoiceMatchForApproval()
                                             throws MXException,
                                                    java.rmi.RemoteException
        Check if any invoice match is currently specified for the invoice line. If no invoice match is available, then check if any match can be found now. If no match is found, raise error. If there are existing invoice match records, then validate the invoice match to make sure that the match is still valid. If not, then raise error.
        Specified by:
        validateInvoiceMatchForApproval in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • checkForServiceProrating

        public void checkForServiceProrating()
                                      throws MXException,
                                             java.rmi.RemoteException
        If the invoice line have PRORATE = Y, PRORATECOST != 0 (should we check this?) and there are distributions existing for any of the invoice lines (i.e. there are invoice lines with more than one invoice cost line), than raise error - Cannot prorate services on an invoice with distributed invoice lines.
        Specified by:
        checkForServiceProrating in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, MultiCostsForProrate) Cannot prorate services.
        MXException
        java.rmi.RemoteException
      • checkForPOLineTolerance

        public void checkForPOLineTolerance(java.lang.Double upperTolerancePct,
                                            java.lang.Double lowerTolerancePct,
                                            java.lang.Double upperToleranceAmt,
                                            java.lang.Double lowerToleranceAmt)
                                     throws MXException,
                                            java.rmi.RemoteException
        For each invoice line that refers to a PO line, a check is made to ensure that the cost on the invoice is not too different from the cost specified on the PO line. This check is made based on the values specified for TOLERANCE.UPPERINVOICEPCT / TOLERANCE.LOWERINVOICEPCT and TOLERANCE.UPPERINVOICEAMT / TOLERANCE.LOWERINVOICEAMT attributes. Tolerance Checking is always done in Base Currency1. The folowing checks are being done:
        1. Raise error if Cost Diff > UPPERINVOICEMT, where UPPERINVOICEAMT is NOT NULL.
        2. Raise error if Cost Diff < LOWERINVOICEAMT, where LOWERINVOICEAMT is NOT NULL.
        3. Raise error if Cost Diff > PO Line Total * UPPERINVOICEPCT, where UPPERINVOICEPCT is NOT NULL.
        4. Raise error if Cost Diff < PO Line Total * LOWERINVOICEPCT, where LOWERINVOICEPCT is NOT NULL.
        Specified by:
        checkForPOLineTolerance in interface InvoiceLineRemote
        Parameters:
        upperTolerancePct - The value specified in TOLERANCE.UPPERINVOICEPCT.
        lowerTolerancePct - The value specified in TOLERANCE.LOWERINVOICEPCT.
        UpperToleranceAmt - The value specified in TOLERANCE.UPPERINVOICEAMT.
        lowerToleranceAmt - The value specified in TOLERANCE.LOWERINVOICEAMT.
        Throws:
        MXApplicationException - (invoice, ExceedPOTolerance) Tolerance level exceeded.
        MXApplicationException - (invoice, LesThanPOTolerance) Less than allowed PO tolerance.
        MXException
        java.rmi.RemoteException
      • createDefaultServiceReceipt

        public MboRemote createDefaultServiceReceipt()
                                              throws MXException,
                                                     java.rmi.RemoteException
        Create a receipt by invoice. It sets all the values on receipt based on the information on invoicecost, invoiceline and invoice. This function is used by the functions to create different receipts by invoice.
        Specified by:
        createDefaultServiceReceipt in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • createDefaultMaterialReceipt

        public MboRemote createDefaultMaterialReceipt()
                                               throws MXException,
                                                      java.rmi.RemoteException
        Create a receipt by invoice. It sets all the values on receipt based on the information on invoicecost, invoiceline and invoice. This function is used by the functions to create different receipts by invoice.
        Specified by:
        createDefaultMaterialReceipt in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • createDefaultReceipt

        public MboRemote createDefaultReceipt()
                                       throws MXException,
                                              java.rmi.RemoteException
        Create a receipt attach to the receipt set owned by invoice. This method sets the default value to the receipt created for this invoiceline. The default fields set include ponum, polinenum, taxcode, currencycode, exchangerate and so on. This function should called first any time when a receipt is created for any purpose by an invoiceline. The receipt type is determined by the invoiceline.
        Specified by:
        createDefaultReceipt in interface InvoiceLineRemote
        Returns:
        the created receipt mboRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • createDefaultReceipt

        public MboRemote createDefaultReceipt(MboSetRemote desiredReceipts)
                                       throws MXException,
                                              java.rmi.RemoteException
        Create a receipt attach to the disired receipt set. This method sets the default value to the receipt created for this invoiceline. The default fields set include ponum, polinenum, taxcode, currencycode, exchangerate and so on. The approved flag is set to true for service and null for material receipts. The type is defaulted to INVOICE. This function should called first any time when a receipt is created for any purpose by an invoiceline. The receipt type and set will be determined by the invoiceline itself if desired receipts parameter is null. Otherwise, it will be desired receipts.
        Specified by:
        createDefaultReceipt in interface InvoiceLineRemote
        Parameters:
        desiredReceipts - desired receipts mbo set which the newly created receipt will belong too.
        Returns:
        the created receipt mboRemote, it can be material receipt or service receipt. This receipt is in the set of disired receipts mbo set.
        Throws:
        MXException
        java.rmi.RemoteException
      • createReceipts

        public void createReceipts()
                            throws MXException,
                                   java.rmi.RemoteException
        For each invoicecost, this function creates the receipt and invoice match from invoicecost for the line. This function is called by invoice approval. The receipt is created for the distributed costs or as a brand new receipt if receipt was not required on the po-poline.
        Specified by:
        createReceipts in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • calcProrateCostForReceipt

        public double calcProrateCostForReceipt()
                                         throws MXException,
                                                java.rmi.RemoteException
        Calculate the proratecost which will be put on the receipt. If it is a direct issue, the entire prorate cost will be put on the receipt, otherwise, only part of it corresponding to the current balance in inventory will be adjusted. This function is only called by create receipt for proratecost. It returns the prorate cost in base currency.
        Specified by:
        calcProrateCostForReceipt in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • getRatioForTransaction

        public double getRatioForTransaction()
                                      throws MXException,
                                             java.rmi.RemoteException
        When the receipt is created, the average cost of the storeroom is updated to reflect the value. Depending on the current balance at the time of receipt, either the entire value of the cost should be applied to the storeroom, either the entire value or partial value is applied. This ratio is applied to both variance and prorate cost.
        Throws:
        MXException
        java.rmi.RemoteException
      • needProcessVariance

        public boolean needProcessVariance()
                                    throws MXException,
                                           java.rmi.RemoteException
        Does this invoice line need to process variance? If the invoice doesn't refer to a PO - POLine, then only brand new receipt will be written for this invoiceline, so, no variance calculation is needed. Also, if this invoiceline refers to a PO - POLine, but this POLine's receiptreqd=N. a brand new receipt will be written, so, no variance calculation needed either. For all the other cases, calculation for variance is needed.
        Specified by:
        needProcessVariance in interface InvoiceLineRemote
        Throws:
        MXApplicationException
        MXException
        java.rmi.RemoteException
      • createTransactionsAfterAppr

        public void createTransactionsAfterAppr(double currencyVar,
                                                double priceVar)
                                         throws MXException,
                                                java.rmi.RemoteException
        This method is used to create invoice variance transactions and is called through the invoice mbo. Mainly for ERP group's use.
        Specified by:
        createTransactionsAfterAppr in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • findOrigReceiptSum

        public double findOrigReceiptSum(java.lang.String attribute)
                                  throws MXException,
                                         java.rmi.RemoteException
        Find the sum of certain numerical attibute of the receipts matching the 100% invoicecost line of the invoiceline.
        Specified by:
        findOrigReceiptSum in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceTrans

        public void createInvoiceTrans()
                                throws MXException,
                                       java.rmi.RemoteException
        This method calls the methods that create the INVOICETRANS object.
        Throws:
        MXException
        java.rmi.RemoteException
      • returnGls

        public java.util.Vector returnGls(boolean updateInventory,
                                          boolean varType)
                                   throws MXException,
                                          java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • returnGls

        public java.util.Vector returnGls(boolean updateInventory,
                                          boolean varType,
                                          MboRemote transMbo)
                                   throws MXException,
                                          java.rmi.RemoteException
        This method is a private method that gets the PONUM-POLINENUM from the invoice line and based on this info grabs the POLINE.From the POLINE it gets hold of the ITEM-STORELOC and gets the corresponding INVENTORY record for the ITEM-STORELOC combination.This method is purely meant for code reduction because both writePriceVarianceToInvoiceTrans() and writeCurrencyVarianceToInvoiceTrans() need to get hold of the GLDEBIT and GLCREDIT account numbers for the ITEM-STORELOC combination and/or from the vendor.
        Throws:
        MXException
        java.rmi.RemoteException
      • getIssue

        public boolean getIssue()
                         throws MXException,
                                java.rmi.RemoteException
        If it is a service, issue is always yes, if not, invoiceline must have a poline, get it's issue flag from the poline.
        Specified by:
        getIssue in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • invoiceMatch

        protected void invoiceMatch()
                             throws MXException,
                                    java.rmi.RemoteException
        This method matches the invoice line with one or more uninvoiced receipts of the PO-POLine indicated on the invoice. Depending on the type of the POLine, the match will be chosen either from material receipts or service receipts. This method will find the match, write the invoicematch table and update the in-memory representation of the match on invoice object for the following match processes of other invoice lines of the same invoice. The overall procedure of this method would be:
        1. First decide if this invoiceline needs invoice match or not. If receipt was not required, invoicematch is not needed. If receipt was required, continue the match. If it is a service line, the match should be among service receipts otherwise material receipts.
        2. Depends on if the invoiceline is a service line or a material line call owner invoice's getAllUninvoicedServReceipts() or getAllInvoicedMatReceipts() respectively. These functions will construct the in-memory representation of the uninvoice receipts information if it has not been constructed for this invoice.
        3. Find the matched receipts for this line by calling owner invoice's findMatch (uninvoiced material receipts with their uninvoiced cost/qty minimum value, maximum value, byCost, consider tax or not = false, partial receipt allowed = true). This method follows the algorithm to find one or more receipts to match the invoiceline. since we need the exact match this time, tax will not be considered. The minimum value and the maximum value are the same, which is the unmatched qty of invoiceline when byCost =true, or unmatched cost of invoice line if byCost = false. If the invoiceline is a serviceline, and there is no qty, byCost is true. Please notice that the invoicematch's currency is in invoice's currenty, but receipt's currency is in PO's currency, which indicated on the receipt, they can be different. Also, the quantity on the receipt is in issue unit for material, so, the match considers the conversion rate.
        4. The matched receipts will be written to the invoicematch one by one. The match will be written on behalf of the the first invoicecost line (the original invoicecost, the one with lincecostnum = 1). Call invoicecost's writeToInvoiceMatch(matched receipt, qty, cost) to do this. Since receipt can be partially matched to this invoiceline, the quantity and cost need to be specified. At the meanwhile, this method updates the in-memory representation of the uninvoice receipts.
        This method is called by validateInvoiceMatchForApproval() and save() methods of Invoiceline.
        Throws:
        MXApplicationException - "invoice"="matchNotFound" when matches cannot be found for this invoice line.
        MXException
        java.rmi.RemoteException
      • moveToTop

        public void moveToTop(java.util.Vector receipts,
                              java.lang.String receiptId)
                       throws MXException,
                              java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getUnmatched

        public double getUnmatched()
                            throws MXException,
                                   java.rmi.RemoteException
        Helper function to check if this invoiceline has been fully matched. It looks all of the invoicematches for this invoiceline, and find out if all the qty or cost has been matched.
        Returns:
        unmatched qty or cost for this invoice line. If the poline is by qty, the returned unmatched qty is in issue unit.
        Throws:
        MXException
        java.rmi.RemoteException
      • afterAdd

        public void afterAdd()
                      throws MXException,
                             java.rmi.RemoteException
        Called right after the new Invoiceline mbo is added to the invoiceline set. It creates an invoicecost.
        Throws:
        MXException
        java.rmi.RemoteException
      • getValidateOrder

        public java.lang.String[] getValidateOrder()
        Validation Order for InvoiceLine attributes.
        Overrides:
        getValidateOrder in class Mbo
      • setCurVarTotal

        public void setCurVarTotal(double currencyVariance)
                            throws MXException,
                                   java.rmi.RemoteException
        This method is to be used by ERP to set the global variable curVar when they don't want us to calculate the currency variance instead they do it. This method should always be called before the invoice approval when the external system does the invoice matching and passes it in because in that case it is assumed that they are also calculating the variances.
        Specified by:
        setCurVarTotal in interface InvoiceLineRemote
        Parameters:
        currencyVariance - Currency variance value the global variable curVarTotal is to be set to.
        Throws:
        MXException
        java.rmi.RemoteException
      • setPriceVarTotal

        public void setPriceVarTotal(double priceVariance)
                              throws MXException,
                                     java.rmi.RemoteException
        This method is to be used by ERP to set the global variable priceVar when they don't want us to calculate the price variance instead they do it. This method should always be called before the invoice approval when the external system does the invoice matching and passes it in because in that case it is assumed that they are also calculating the variances.
        Specified by:
        setPriceVarTotal in interface InvoiceLineRemote
        Parameters:
        priceVariance - Price variance value the global variable priceVarTotal is to be set to.
        Throws:
        MXException
        java.rmi.RemoteException
      • copyReceiptPOLineToInvoiceLine

        public void copyReceiptPOLineToInvoiceLine(MboRemote receiptOrPOLine,
                                                   double qty,
                                                   double cost)
                                            throws MXException,
                                                   java.rmi.RemoteException
        This method decides and calls the respective methods to copy receipt or poline info to the newly created invoice line. This method has to called from the InvoiceLine MboSet as it adds the new invoice line.
        Specified by:
        copyReceiptPOLineToInvoiceLine in interface InvoiceLineRemote
        Parameters:
        receiptOrPOLine - The receipt or poline mbo from which the values will be copied.
        qty - Invoice order unit.
        cost - Invoice cost in invoice currency.
        Throws:
        MXException
        java.rmi.RemoteException
      • copyReceiptToInvoiceLine

        public void copyReceiptToInvoiceLine(MboRemote receipt,
                                             double qty,
                                             double cost)
                                      throws MXException,
                                             java.rmi.RemoteException
        Copy the receipt info to the newly created invoiceline. Certain fields are copied and not copied depending upon if the receipt is a material or service. Also some of the attributes are set by copying from the related poline. The user passes in the receipt mbo and the quantity and linecost.
        Parameters:
        receipt - The receipt or poline mbo from which the values will be copied.
        qty - Invoice order unit.
        cost - Invoice cost in invoice currency.
        Throws:
        MXException
        java.rmi.RemoteException
      • copyPOLineToInvoiceLine

        public void copyPOLineToInvoiceLine(MboRemote poLine,
                                            double qty,
                                            double cost)
                                     throws MXException,
                                            java.rmi.RemoteException
        Copy the poline info to the newly created invoiceline. The user passes in the poline mbo and the quantity and linecost.
        Parameters:
        poLine - The poline mbo from which the values will be copied.
        qty - Invoice order unit.
        cost - Invoice cost in invoice currency.
        Throws:
        MXException
        java.rmi.RemoteException
      • createInvoiceCostFromInvoiceLine

        public void createInvoiceCostFromInvoiceLine(MboRemote newInvoiceLine,
                                                     MboRemote poLine)
                                              throws MXException,
                                                     java.rmi.RemoteException
        This method copies the new invoice line and poline or receipt info to the newly created invoice cost. The user has to pass in the invoiceline and poline mbos.
        Throws:
        MXException
        java.rmi.RemoteException
      • copy

        public MboRemote copy(MboSetRemote mboSet)
                       throws MXException,
                              java.rmi.RemoteException
        Overwrite the copy method in MboSet. This method is used by the invoice duplicate to duplicate the invoice line mbos. The invoice cost is also duplicated.
        Specified by:
        copy in interface MboRemote
        Overrides:
        copy in class Mbo
        Parameters:
        mboSet - The set into which the new mbo will be added.
        Returns:
        The new mbo, with values copied from this mbo.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Mbo.copy(MboSetRemote, long)
      • skipCopyField

        protected boolean skipCopyField(MboValueInfo mvi)
                                 throws MXException,
                                        java.rmi.RemoteException
        Overwrites the skipCopyField() in the Mbo. If this field does not need to be copied return true. The following are the InvoiceLine fields will be skipped without being copied to the newly duplicated InvoiceLine:
        1. invoicenum
        2. enterby
        3. enterdate
        4. siteid
        5. 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.duplicate(), Invoice.loadSkipFieldCopyHashSet()
      • canDistributeInvoiceLine

        public void canDistributeInvoiceLine()
                                      throws MXException,
                                             java.rmi.RemoteException
        If the related PO line is already distributed i.e POLINE.DISTRIBUTED=Y, you cannot distribute this invoice line. This method should be called by the GUI when the "Distribute Costs" button on the Invoice Line page is pushed.
        Specified by:
        canDistributeInvoiceLine in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, POLineMissing) Related PO Line is missing.
        MXApplicationException - (invoice, DistributedInPO) Line already distributed in PO.
        MXException
        java.rmi.RemoteException
      • canDistributeProrateInvoiceLine

        public void canDistributeProrateInvoiceLine()
                                             throws MXException,
                                                    java.rmi.RemoteException
        If this invoice line is a prorate line i.e. PRORATESERVICE=Y, you cannot distribute this invoice line. This method should be called by the GUI when the "Distribute Costs" button on the Invoice Line page is pushed.
        Specified by:
        canDistributeProrateInvoiceLine in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, CannotDistProrateLine) Line cannot be distributed as it can be prorated.
        MXException
        java.rmi.RemoteException
      • canAllocateServices

        public void canAllocateServices()
                                 throws MXException,
                                        java.rmi.RemoteException
        You can allocate services only if this invoice line is a prorate line i.e. PRORATESERVICE=Y. This method should be called by the GUI when the "Allocate Services" button on the Invoice Line page is pushed.
        Specified by:
        canAllocateServices in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, CannotAllocateServices) Cannot allocate services as no services to prorate.
        MXException
        java.rmi.RemoteException
      • CanAllocateServIfEnteredOrWappr

        public void CanAllocateServIfEnteredOrWappr()
                                             throws MXException,
                                                    java.rmi.RemoteException
        You can allocate services only if the status of the owner invoice is ENTERED or WAPPR. This method should be called by the GUI when the "Allocate Services" action on the Invoice Line page is used.
        Specified by:
        CanAllocateServIfEnteredOrWappr in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, AllocateServIfEnteredOrWappr) Can allocate services only if invoice status is ENTERED or WAPPR.
        MXException
        java.rmi.RemoteException
      • initRelationship

        public void initRelationship(java.lang.String relationName,
                                     MboSetRemote mboSet)
                              throws MXException,
                                     java.rmi.RemoteException
        The invoicecost should be readonly if it is copied from poline's existing distribution. Also set the editibilty of the invoice cost for this invoice line.
        Overrides:
        initRelationship in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • canDistributeIssueInvoiceLine

        public void canDistributeIssueInvoiceLine()
                                           throws MXException,
                                                  java.rmi.RemoteException
        If the related PO line is a not a direct issue, you cannot distribute this invoice line. Also the invoice line has to be saved before distributing costs. This method should be called by the GUI when the "Distribute Costs" button on the Invoice line page is pushed.
        Specified by:
        canDistributeIssueInvoiceLine in interface InvoiceLineRemote
        Throws:
        MXApplicationException - (invoice, SaveBeforeDistCost) Save before distributing costs.
        MXApplicationException - (invoice, POLineMissing) Related PO Line is missing.
        MXApplicationException - (invoice, POLineNotDirectIssue) PO Line is not a direct issue.
        MXException
        java.rmi.RemoteException
      • updateWOCosts

        public void updateWOCosts()
                           throws MXException,
                                  java.rmi.RemoteException
        This method updates the actual service cost of the workorders which are associated to the related invoice costs of the owner invoice. When approving the invoice, if the invoice line is charged to a service which does not have any ponum or polinenum, we have to update the actual service cost of the workorder on the related invoice cost lines.
        Specified by:
        updateWOCosts in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • undelete

        public void undelete()
                      throws MXException,
                             java.rmi.RemoteException
        This method undeletes an invoice line that has been marked for deletion. All the related invoice costs are also undeleted.
        Specified by:
        undelete in interface MboRemote
        Overrides:
        undelete in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • creatInvTransForProrate

        public void creatInvTransForProrate(double prorateCostForInvTrans)
                                     throws MXException,
                                            java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • getRatioGoesToReceipt

        public double getRatioGoesToReceipt()
                                     throws MXException,
                                            java.rmi.RemoteException
        based on update inventory, current balance, invoiceqty to decide how much goes to receipt.
        Throws:
        MXException
        java.rmi.RemoteException
      • recalcDistribution

        public void recalcDistribution()
                                throws MXException,
                                       java.rmi.RemoteException
        Recalculate the linecost and or quantity based on the same distribution This method should only be called when the line's quantity or cost has changed.
        Throws:
        MXException
        java.rmi.RemoteException
      • addCostFromPOLine

        public void addCostFromPOLine(InvoiceCostSetRemote invCostSet,
                                      MboRemote poLine)
                               throws MXException,
                                      java.rmi.RemoteException
        This method adds new invoice cost lines and copies over the values from PO Cost and PO line. Each related PO Cost line should have one corresponding invoice cost line.
        Specified by:
        addCostFromPOLine in interface InvoiceLineRemote
        Parameters:
        invCostSet - The invoice cost set to which the new lines will be added.
        poLine - The corresponding PO line for this invoice line. Used to get the PO cost.
        Throws:
        MXException
        java.rmi.RemoteException
      • setPriceQtyFields

        public void setPriceQtyFields()
                               throws MXException,
                                      java.rmi.RemoteException
        Based on ContractLine ChgPriceOnUse and ChgQtyOnUse value to set line cost, unit cost, order unit and quantity to be read only or editable. If ChgPriceOnUse is true, UnitCost and LineCost are editable. Otherwise, they are read only. If ChgQtyOnUse is true, OrderQty and OrderUnit are editable. Otherwise, they are read only.
        Specified by:
        setPriceQtyFields in interface InvoiceLineRemote
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        InvoiceLine.setPriceQtyFields()
      • getDefaultTaxExempt

        public void getDefaultTaxExempt(MboRemote itemRemote,
                                        MboRemote invVendor)
                                 throws MXException,
                                        java.rmi.RemoteException
        This method gets taxexempt for the poline/prline based on taxorder
        Throws:
        MXException
        java.rmi.RemoteException
      • getInventoryCurbal

        public double getInventoryCurbal()
                                  throws MXException,
                                         java.rmi.RemoteException
        10-15967
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getActivePO

        public MboRemote getActivePO()
                              throws MXException,
                                     java.rmi.RemoteException
        Based on Invoice Line ponum and po site to find an active PO that in APPR, INPRG or CLOSE status.
        Returns:
        a PO mbo or null
        Throws:
        MXException
        java.rmi.RemoteException
      • updateConsTransInvoiceNum

        public void updateConsTransInvoiceNum(boolean clearInvoiceNum)
                                       throws MXException,
                                              java.rmi.RemoteException
        Updated 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 delete the invoice line, this method 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
      • setReadOnlyForConsInvoice

        public void setReadOnlyForConsInvoice()
                                       throws MXException,
                                              java.rmi.RemoteException
        Set these fields readonly for consignment type invoice.
        Throws:
        MXException
        java.rmi.RemoteException
      • getConsTransMbo

        public MboRemote getConsTransMbo(java.lang.String origTransaction,
                                         int transID)
                                  throws MXException,
                                         java.rmi.RemoteException
        Utility method to get the related transacion mbo in case of consignment invoice.
        Parameters:
        origTransaction -
        transID -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • save

        public void save()
                  throws MXException,
                         java.rmi.RemoteException
        Override the super class save. If the invoiceline is created for a consignment item and for integration, we have to update the transaction with the invoice number.
        Overrides:
        save in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • clearLabTransOnDelete

        public void clearLabTransOnDelete()
                                   throws MXException,
                                          java.rmi.RemoteException
        IV30627/12-14489/defect 59573: clear invoicenum and invoicelinenum from labtrans if invoice is being deleted.
        Throws:
        MXException
        java.rmi.RemoteException
      • setPOLineFromCopyPOLine

        public void setPOLineFromCopyPOLine(MboRemote poLineFromCopyPOline)
                                     throws MXException,
                                            java.rmi.RemoteException
        IV35816/71201:the for performance: poLineCopyPOLine mbo is the POLine shown on the Copy POLine dialog. It is not invoiceline.getMboSet("POLINE")
        Parameters:
        poLineFromCopyPOline -
        Throws:
        MXException
        java.rmi.RemoteException
      • getPOLineFromCopyPOLine

        public MboRemote getPOLineFromCopyPOLine()
                                          throws MXException,
                                                 java.rmi.RemoteException
        IV35816/7120: for performance
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException