Ignore:
Timestamp:
Apr 21, 2011, 3:29:47 PM (14 years ago)
Author:
gav
Message:

Purchase Order first draft as per ticket #30, by John Yesberg.

Location:
branches/features/purchaseOrders/grails-app/services
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/features/purchaseOrders/grails-app/services/CreateDataService.groovy

    r848 r891  
    8989        createBaseEntryTypes()
    9090
     91
    9192        // Record that data has been created.
    9293        appConfigService.set("baseDataCreated")
     
    144145//         createDemoMaintenanceActions()
    145146        createDemoTaskRecurringSchedules()
     147
     148        // PurchaseOrderNumbers
     149        createDemoPurchaseOrderNumbers()
    146150
    147151        // Record that data has been created.
     
    17361740    }
    17371741
     1742    def createDemoPurchaseOrderNumbers() {
     1743        for (int i=10000; i<10100; i++) {
     1744            saveAndTest(new PurchaseOrderNumber(value:"P${i}"))
     1745        }
     1746    }
     1747
    17381748    /**
    17391749    * SearchableIndex and mirroring is disabled at startup.
  • branches/features/purchaseOrders/grails-app/services/InventoryItemService.groovy

    r727 r891  
    6363                }
    6464                else {
    65                     order('purchaseOrderNumber', 'desc')
     65                    order('purchaseOrder', 'desc')
    6666                    order('id', 'asc')
    6767                }
  • branches/features/purchaseOrders/grails-app/services/InventoryPurchaseService.groovy

    r717 r891  
    66    def dateUtilService
    77    def inventoryMovementService
     8    def purchaseOrderService
    89
    910    /**
     
    2324        result.totalReceivedAmount = 0
    2425        result.totalPaymentApproved = 0
    25         InventoryItemPurchase.withCriteria {
    26             eq("inventoryItem", order.inventoryItem)
    27             eq("purchaseOrderNumber", order.purchaseOrderNumber)
    28         }.each() {
     26        def purchaseOrder = order.purchaseOrder
     27        def relevantLineItems = purchaseOrder.inventoryItemPurchases.findAll{it.inventoryItem == order.inventoryItem}
     28//        InventoryItemPurchase.withCriteria {
     29//            eq("inventoryItem", order.inventoryItem)
     30//            eq("purchaseOrderNumber", order.purchaseOrderNumber)
     31//        }.each() {
     32        relevantLineItems.each {
    2933            if(it.inventoryItemPurchaseType.id == 1L) { // Orders.
    3034                result.totalOrdered += it.quantity
     
    7781
    7882        namedParams.inventoryItem = inventoryItemPurchase.inventoryItem
    79         namedParams.purchaseOrderNumber = inventoryItemPurchase.purchaseOrderNumber
     83        namedParams.purchaseOrder = inventoryItemPurchase.purchaseOrder
    8084        namedParams.orderPlaced = InventoryItemPurchaseType.read(1)
    8185
    8286        def order = InventoryItemPurchase.find("from InventoryItemPurchase as p \
    8387                                                                                where( p.inventoryItem = :inventoryItem \
    84                                                                                             and p.purchaseOrderNumber = :purchaseOrderNumber \
     88                                                                                            and p.purchaseOrder = :purchaseOrder \
    8589                                                                                            and p.inventoryItemPurchaseType = :orderPlaced )",
    8690                                                                            namedParams)
     
    322326
    323327            result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params)
    324             result.inventoryItemPurchaseInstance.purchaseOrderNumber = result.inventoryItemPurchaseInstance.purchaseOrderNumber.trim()
     328            result.inventoryItemPurchaseInstance.purchaseOrder = purchaseOrderService.getOrCreatePurchaseOrder(params)
    325329            result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser
    326330            result.inventoryItemPurchaseInstance.inventoryItemPurchaseType = InventoryItemPurchaseType.read(1) // Order
     
    344348
    345349        } // end withTransaction
    346     } // save()
     350    }  // save()
    347351
    348352    def receiveSave(params) {
     
    363367            result.orderId = order.id
    364368
     369            def purchaseOrderNumber = PurchaseOrderNumber.findByValue(order.purchaseOrderNumber)
     370            def purchaseOrder = purchaseOrderNumber.purchaseOrder
     371
    365372            result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params)
    366373            result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser
    367             result.inventoryItemPurchaseInstance.purchaseOrderNumber = order.purchaseOrderNumber
     374            result.inventoryItemPurchaseInstance.purchaseOrder = purchaseOrder
    368375            result.inventoryItemPurchaseInstance.costCode = order.costCode
    369376            result.inventoryItemPurchaseInstance.orderValueCurrency = order.orderValueCurrency
     
    438445            result.inventoryItemPurchaseInstance = new InventoryItemPurchase(params)
    439446            result.inventoryItemPurchaseInstance.enteredBy = authService.currentUser
    440             result.inventoryItemPurchaseInstance.purchaseOrderNumber = order.purchaseOrderNumber
     447            result.inventoryItemPurchaseInstance.purchaseOrder = order.purchaseOrder
    441448            result.inventoryItemPurchaseInstance.costCode = order.costCode
    442449            result.inventoryItemPurchaseInstance.orderValueCurrency = order.orderValueCurrency
Note: See TracChangeset for help on using the changeset viewer.