psdi.app.invoice

Class InvoiceCost

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


    public class InvoiceCost
    extends Mbo
    implements InvoiceCostRemote
    Mbo object to represent InvoiceCost. InvoiceCost object contains the accounting distribution/charge details for the invoice line. The cost of an individual invoice line is spread to more than one general ledger account, work order, location, or piece of asset. Each invoice line should have at least one invoice cost line.

    See Invoice Package description.

    The key attributes for this object are InvoiceNum, InvoiceLineNum and CostLineNum.

    The attributes in this object are as follows:

    Attribute NameAttribute Description
    ChargeStoreYes/No field. Yes indicates that the cost for this line item should be accumulated in the Inventory Cost field on the asset with which this line is associated.
    CostLineNumUnique system generated invoice cost line number.
    AssetNumThe asset to which costs for the service should to be charged. Foreign key to Asset.
    FinCntrlIDFinancial Control Identifier.
    GLCreditAcctThe general ledger account code to be credited for this cost distribution line.
    GLDebitAcctThe general ledger account code to be debited the cost of this invoice line item, taken from the PO line (if one is specified).
    InvoiceLineNumThe invoice line number to which this invoice cost line is associated.
    InvoiceNumIdentifier of the invoice.
    LineCostThe amount to be charged to the work order, location, asset, or debit GL account, named for this line.
    LocationLocation where the materials and services were used, displayed from the PO line. Foreign key to Location.
    MemoNote entered by user regarding this distribution.
    OrgIDOrganization Identifier.
    PercentageThe percent of invoice line cost represented by the cost distribution line you are entering.
    QuantityThe quantity to be charged to the work order, location, asset, or debit GL account, named for this line.
    RefWOThe referenced work order number
    SiteIDSite Identifier.
    TaskIDThe work order's task id associated with this line item.
    UnitCostCost per unit of the item, displayed from the invoice line.
    VendorSupplier of the invoice. Foreign key to Company.
    WONumWork order number to be charged. Foreign key to WO.
    ICT1 - ICT3Extra fields.
    • Constructor Detail

      • InvoiceCost

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

      • init

        public void init()
                  throws MXException
        Initialized Invoice cost mbo. Set some fields to readonly when fetched from database.
        Overrides:
        init in class Mbo
        Throws:
        MXException
      • add

        public void add()
                 throws MXException,
                        java.rmi.RemoteException
        This is called when a new invoice cost is added to the InvoiceCost 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
        chargestoreNo
        costlinenumAdd one to the existing maximum value
        glcreditacctVendor's apsuspenseacc(if applicable)
        invoicenumOwner Invoice's invoicenum
        linecostOwner InvoiceLine's linecost
        percentage100
        quantityOwner InvoiceLine's quantity
        unitcostOwner InvoiceLine's unitcost
        vendorOwner InvoiceLine's vendor
        Specified by:
        add in interface MboRemote
        Overrides:
        add in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • canDelete

        public void canDelete()
                       throws MXException,
                              java.rmi.RemoteException
        Can this invoiceCost be deleted? It cannot be deleted if it is readonly and also if it is not the only invoicecost for this invoiceline.
        Overrides:
        canDelete in class Mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • delete

        public void delete(long accessModifier)
                    throws MXException,
                           java.rmi.RemoteException
        Delete the invoicecost record after checking if it can be deleted. invoiceqty, linecost and unitcost are set back to editable if there is only one invoicecost remained.
        Specified by:
        delete in interface MboRemote
        Overrides:
        delete in class Mbo
        Parameters:
        accessModifier - The bitwise flag specified to determine if certain normal security checks are to be bypassed for this delete request. For example: if the accessModifer is NOACCESSCHECK, then the check for the object's NODELETE flag and the call to the object's canDelete() method will not be performed. If the accessModifer is NONE, then all the access checks are performed before this object is marked delete.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        Mbo.delete(long)
      • clearInvCostPOLine

        public void clearInvCostPOLine()
                                throws MXException,
                                       java.rmi.RemoteException
        Clear the fields copied from poline on deleting the polinenum on the InvoiceLine. Also set fields to default values where ever applicable. This is called by the field action of clearing invoiceline's polinenum.
        Specified by:
        clearInvCostPOLine in interface InvoiceCostRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • createReceiptForProrate

        public void createReceiptForProrate()
                                     throws MXException,
                                            java.rmi.RemoteException
        Create material receipt for prorated cost of the invoice line, if updateinventory is true and there are balance in the storeroom, which its invoice cost is not distributed. The material receipt will have quanity and linecost being 0, but with a non-zero prorate cost. Create invtrans when updateinventory is false or any remaining quantity not covered by the receipt. This is only called when there is only one invoicecost.
        Specified by:
        createReceiptForProrate in interface InvoiceCostRemote
        Throws:
        MXException
        java.rmi.RemoteException
      • writeToInvoiceMatch

        public MboRemote writeToInvoiceMatch(MboRemote receipt,
                                             double qty,
                                             double cost)
                                      throws MXException,
                                             java.rmi.RemoteException
        This method writes the invoice match between this cost line and the receipt specified. Since multiple receipts can be matched to the same invoicecost due to partial receiving, the quantity or cost needs to be specified as parameters. This method will be called during invoicematching of the invoice line when the invoice is being approved. It is called on the invoicecost with costnum=1. If there are multiple receipts matched to this invoiceline, this method will be called multiple times. The detailed information about what should be written to the invoicematch table is omitted here because the overloaded function is already written.
        Specified by:
        writeToInvoiceMatch in interface InvoiceCostRemote
        Parameters:
        The - receipt which is the match or one of the matches of the invoiceline.
        qty - matched quantity in invoice's order unit.
        coust - matched cost in invoice's currency.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        overloaded form which the invoicecost is completely matched with only the receipt specified.
      • setReadonly

        public void setReadonly()
                         throws MXException,
                                java.rmi.RemoteException
        convenient function to set certain fields to readonly or not.
        Throws:
        MXException
        java.rmi.RemoteException
      • isEditabilitySetByPO

        public boolean isEditabilitySetByPO()
                                     throws MXException,
                                            java.rmi.RemoteException
        Method to indicate if the editibility of the invoice cost fields should be set based on the corresponding poline info. The following rules apply: 1) If the poline related to the owner invoice line is already distributed, return true i.e. cannot distribute invoiceline. 2) Only lines which are direct issue and are not distributed at the poline level should be allowed distribution here.
        Returns:
        boolean True if editability should be based on poline info, false otherwise.
        Throws:
        MXException
        java.rmi.RemoteException
      • appValidate

        public void appValidate()
                         throws MXException,
                                java.rmi.RemoteException
        Pre-save validation method. Based on a maxvar value check if the GL debit and credit accounts are required for this transaction. If at least one of the following: WONUM, LOCATION, ASSETNUM or GLDEBITACCT does not have a value, and the related invoiceline does not have an item belonging to a storeroom, return error. Also validate the debit GL Account and credit GL Account to be fully specified.
        Overrides:
        appValidate in class Mbo
        Throws:
        MXApplicationException - (invoice, WOAssetLocGLDebitNull) One of the following does not have a value: wonum, assetnum, location, or gldebitacct.
        MXException
        java.rmi.RemoteException
      • getValidateOrder

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

        protected boolean skipCopyField(MboValueInfo mvi)
                                 throws MXException,
                                        java.rmi.RemoteException
        Overrides the skipCopyField() in the Mbo. If this field does not need to be copied return true. The following are the InvoiceCost fields will be skipped without being copied to the newly duplicated InvoiceCost:
        1. invoicenum
        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()