Changeset 633 for trunk/grails-app/services
- Timestamp:
- Jul 19, 2010, 8:47:38 AM (15 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/CreateDataService.groovy
r622 r633 115 115 116 116 // Person and Utils 117 createDemoPersons()118 117 createDemoSites() 119 118 createDemoDepartments() … … 121 120 createDemoManufacturers() 122 121 createDemoProductionReference() 122 createDemoPurchasingGroups() /// @todo: Perhaps a 'createQuickStartData' method? 123 123 createDemoCostCodes() 124 createDemoPersons() 124 125 125 126 // Assets … … 307 308 personInstance.addToAuthorities(Authority.get(2)) // ROLE_Manager. 308 309 personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. 310 personInstance.addToPersonGroups(PersonGroup.get(1)) 311 personInstance.addToPurchasingGroups(PurchasingGroup.get(1)) 312 personInstance.addToPurchasingGroups(PurchasingGroup.get(2)) 309 313 310 314 //Person #4 … … 697 701 } 698 702 703 void createDemoPurchasingGroups() { 704 705 // PurchasingGroup 706 def purchasingGroupInstance 707 708 purchasingGroupInstance = new PurchasingGroup(name:"R&M") 709 saveAndTest(purchasingGroupInstance) 710 711 purchasingGroupInstance = new PurchasingGroup(name:"Raw Materials") 712 saveAndTest(purchasingGroupInstance) 713 714 purchasingGroupInstance = new PurchasingGroup(name:"Safety") 715 saveAndTest(purchasingGroupInstance) 716 } 717 699 718 def createDemoCostCodes() { 700 719 … … 703 722 704 723 // CostCode #1 705 costCodeInstance = new CostCode(name: "RM Reelstand") 724 costCodeInstance = new CostCode(name: "Reelstand.172", 725 purchasingGroup: PurchasingGroup.get(1)) 706 726 saveAndTest(costCodeInstance) 707 727 708 728 // CostCode #2 709 costCodeInstance = new CostCode(name: "CAPEX Reelstand") 729 costCodeInstance = new CostCode(name: "Reelstand.CAPEX", 730 purchasingGroup: PurchasingGroup.get(1)) 731 saveAndTest(costCodeInstance) 732 733 // CostCode #2 734 costCodeInstance = new CostCode(name: "PrintUnit.123", 735 purchasingGroup: PurchasingGroup.get(3)) 710 736 saveAndTest(costCodeInstance) 711 737 } -
trunk/grails-app/services/InventoryPurchaseService.groovy
r610 r633 89 89 } 90 90 91 /** 92 * Get costCodes by person and the purchasingGroups they have been assigned. 93 * @param person A Person, defaults to currentUser. 94 * @returns A list of CostCodes. 95 */ 96 def getCostCodesByPerson(person = authService.currentUser) { 97 if(person.purchasingGroups) { 98 CostCode.withCriteria { 99 eq('isActive', true) 100 or { 101 person.purchasingGroups.each() { purchasingGroup -> 102 eq('purchasingGroup', purchasingGroup) 103 } 104 } 105 }.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } // withCriteria 106 } 107 else 108 [] 109 } // getCostCodesByPerson 110 111 /** 112 * Check if a person is in a purchasing group. 113 * @param person A PurchasingGroup to check for. 114 * @param person A Person, defaults to currentUser. 115 * @returns True if person is in group. 116 */ 117 def isPersonInPurchasingGroup(purchasingGroup, person = authService.currentUser) { 118 for(pg in person.purchasingGroups) { 119 if(pg.id == purchasingGroup.id) 120 return true 121 } 122 } // isPersonInPurchasingGroup 123 91 124 def delete(params) { 92 125 InventoryItemPurchase.withTransaction { status ->
Note: See TracChangeset
for help on using the changeset viewer.