Class CostingUtils


  • public class CostingUtils
    extends Object
    • Constructor Detail

      • CostingUtils

        public CostingUtils()
    • Method Detail

      • getTransactionCost

        public static BigDecimal getTransactionCost​(MaterialTransaction transaction,
                                                    Date date,
                                                    boolean calculateTrx,
                                                    Currency currency)
        Calculates the total cost amount of a transaction including the cost adjustments done until the given date.
        Parameters:
        transaction - MaterialTransaction to get its cost.
        date - The Date it is desired to know the cost.
        calculateTrx - boolean flag to force the calculation of the transaction cost if it is not calculated.
        currency - The Currency to calculate the amount.
        Returns:
        The total cost amount.
      • getStandardCost

        public static BigDecimal getStandardCost​(Product product,
                                                 Organization org,
                                                 Date date,
                                                 HashMap<CostingAlgorithm.CostDimension,​BaseOBObject> costDimensions,
                                                 boolean recheckWithoutDimensions,
                                                 Currency convCurrency)
                                          throws OBException
        Calculates the standard cost of a product on the given date and cost dimensions.
        Parameters:
        product - The Product to get its Standard Cost
        date - The Date to get the Standard Cost
        costDimensions - The cost dimensions to get the Standard Cost if it is defined by some of them.
        recheckWithoutDimensions - boolean flag to force a recall the method to get the Standard Cost at client level if no cost is found in the given cost dimensions.
        convCurrency - The Currency to calculate the amount.
        Returns:
        the Standard Cost.
        Throws:
        OBException - when no standard cost is found.
      • hasStandardCostDefinition

        public static boolean hasStandardCostDefinition​(Product product,
                                                        Organization org,
                                                        Date date,
                                                        HashMap<CostingAlgorithm.CostDimension,​BaseOBObject> costDimensions,
                                                        boolean recheckWithoutDimensions)
        Check the existence of a standard cost definition of a product on the given date and cost dimensions.
        Parameters:
        product - The Product to get its Standard Cost
        date - The Date to get the Standard Cost
        costDimensions - The cost dimensions to get the Standard Cost if it is defined by some of them.
        recheckWithoutDimensions - boolean flag to force a recall the method to get the Standard Cost at client level if no cost is found in the given cost dimensions.
        Returns:
        the Standard Cost. Null when no definition is found.
      • getStandardCostDefinition

        public static Costing getStandardCostDefinition​(Product product,
                                                        Organization org,
                                                        Date date,
                                                        HashMap<CostingAlgorithm.CostDimension,​BaseOBObject> costDimensions,
                                                        boolean recheckWithoutDimensions)
        Calculates the standard cost definition of a product on the given date and cost dimensions.
        Parameters:
        product - The Product to get its Standard Cost
        date - The Date to get the Standard Cost
        costDimensions - The cost dimensions to get the Standard Cost if it is defined by some of them.
        recheckWithoutDimensions - boolean flag to force a recall the method to get the Standard Cost at client level if no cost is found in the given cost dimensions.
        Returns:
        the Standard Cost. Null when no definition is found.
      • getStandardCostDefinition

        public static Costing getStandardCostDefinition​(Product product,
                                                        Organization org,
                                                        Date date,
                                                        HashMap<CostingAlgorithm.CostDimension,​BaseOBObject> costDimensions,
                                                        boolean recheckWithoutDimensions,
                                                        String costtype)
        Calculates the standard cost definition of a product on the given date and cost dimensions.
        Parameters:
        product - The Product to get its Standard Cost
        date - The Date to get the Standard Cost
        costDimensions - The cost dimensions to get the Standard Cost if it is defined by some of them.
        recheckWithoutDimensions - boolean flag to force a recall the method to get the Standard Cost at client level if no cost is found in the given cost dimensions.
        Returns:
        the Standard Cost. Null when no definition is found.
      • getMaxTransactionDate

        public static Date getMaxTransactionDate​(Organization org)
        Returns the max transaction date with cost calculated
      • periodClosed

        public static Period periodClosed​(Organization org,
                                          Date dateFrom,
                                          Date dateTo,
                                          String docType)
                                   throws javax.servlet.ServletException
        Search period control closed between dateFrom and dateTo
        Throws:
        javax.servlet.ServletException
      • getCostingRuleStartingDate

        public static Date getCostingRuleStartingDate​(CostingRule rule)
        Returns the Starting Date of a Costing Rule, if is null returns 01/01/1900
      • getCostingRuleFixBackdatedFrom

        public static Date getCostingRuleFixBackdatedFrom​(CostingRule rule)
        Returns the Fix Backdated From of a Costing Rule, if is null returns 01/01/1900
      • checkValidOrganization

        public static void checkValidOrganization​(String processId,
                                                  Organization scheduledOrg)
        Throws an OBException when the processId is the CostingBackground and it is being executed by an organization which has a legal entity as an ancestor.
        Parameters:
        processId - This is the process Id being executed. The method only runs the validation when the process ID is equal to CostingBackground.AD_PROCESS_ID
        scheduledOrg - the organization that runs the process
      • isLastOpeningTransaction

        public static boolean isLastOpeningTransaction​(MaterialTransaction trx,
                                                       boolean includeWarehouseDimension)
        Check if trx is the last opening one of an Inventory Amount Update
      • isAllowNegativeStock

        @Deprecated
        public static boolean isAllowNegativeStock​(Client client)
        Deprecated.
      • isNegativeStockEnabledForAnyStorageBin

        public static boolean isNegativeStockEnabledForAnyStorageBin​(Client client)
      • isNegativeStockAllowedForShipmentInout

        public static boolean isNegativeStockAllowedForShipmentInout​(String shipmentInOutId)
      • getOrganizationForCloseAndOpenInventories

        public static Organization getOrganizationForCloseAndOpenInventories​(String OrgId,
                                                                             Warehouse warehouse)
        For the given Warehouse parameter, this method returns an Organization that allows to create Transactions. If the Organization of the Warehouse is valid, it returns this Organization, if not, it looks for a valid one in the parent Organizations of the Warehouse Organization. If no valid Organization is found, the Organization of the id given as a parameter is returned.
        Parameters:
        OrgId - The identifier of an Organization object
        warehouse - The Warehouse for which the Opening and Close Inventories are going to be created
        Returns:
        An Organization that allows to create transactions that is the Organization or one of the parent Organizations of the given Warehouse. If no one is found, it returns the Organization of the given id as a parameter
      • getLastDate

        public static Date getLastDate()