The Pharmacy POS System Backend is the server-side component of our comprehensive pharmacy management software. It is developed using Spring Boot, Java, Spring Security ,and Microservices Architecture
Pull Request: Fix Issue with Employer ID in Response
Issue Description
92 ID retrieve issue in create cashier endpoint
Problem
When creating a new cashier using the API endpoint /employers/save-without-image, the response always returns an ID of 0 instead of the expected unique ID for the newly created cashier.
Steps to Reproduce
Send a POST request to the /employers/save-without-image endpoint with valid data for creating a new cashier.
Receive the response from the server.
Check the ID field in the response.
Expected Behavior
The response should include a unique ID for the newly created cashier, allowing us to identify and work with this cashier in subsequent operations.
Actual Behavior
The ID in the response is consistently returning as 0, which does not match the expected behavior.
Updated the service layer to ensure that the ID of the newly created cashier is correctly retrieved and included in the response.
Modified the controller to properly map the returned employer ID in the response data.
Affected Files
EmployerServiceImpl.java
EmployerController.java
Test Plan
Added unit tests to verify the correct ID is returned in the response after creating a new cashier.
Ensured that existing tests pass without any regression.
Manually tested the /employers/save-without-image endpoint to confirm the fix.
Example Test
A test to ensure that the correct ID is returned:
@Test
void createEmployerWithoutImage_ReturnsCorrectId() throws Exception {
EmployerDTO employerDTO = new EmployerDTO();
employerDTO.setEmployerFirstName("John");
employerDTO.setEmployerLastName("Doe");
// set other properties...
when(employerService.saveEmployerWithoutImage(any(EmployerDTO.class))).thenReturn(employerDTO);
mockMvc.perform(post("/employers/save-without-image")
.contentType(MediaType.APPLICATION_JSON)
.content(asJsonString(employerDTO)))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.employerId").value(employerDTO.getEmployerId()));
}
Screenshots
Before Fix
After Fix
Conclusion
This pull request addresses the issue of the response always returning an ID of 0 when creating a new cashier. The fix ensures that the correct unique ID is included in the response, improving the functionality and reliability of the /employers/save-without-image endpoint.
Your feedback on this fix and any suggestions for further improvement are highly appreciated.
Best regards,
Pramitha Jauasooriya
Backend Developer at LifePill
Pull Request: Fix Issue with Employer ID in Response
Issue Description
92 ID retrieve issue in create cashier endpoint
Problem
When creating a new cashier using the API endpoint
/employers/save-without-image
, the response always returns an ID of 0 instead of the expected unique ID for the newly created cashier.Steps to Reproduce
/employers/save-without-image
endpoint with valid data for creating a new cashier.Expected Behavior
The response should include a unique ID for the newly created cashier, allowing us to identify and work with this cashier in subsequent operations.
Actual Behavior
The ID in the response is consistently returning as 0, which does not match the expected behavior.
Example response:
Solution
Changes Made
Affected Files
EmployerServiceImpl.java
EmployerController.java
Test Plan
/employers/save-without-image
endpoint to confirm the fix.Example Test
A test to ensure that the correct ID is returned:
Screenshots
Before Fix
After Fix
Conclusion
This pull request addresses the issue of the response always returning an ID of 0 when creating a new cashier. The fix ensures that the correct unique ID is included in the response, improving the functionality and reliability of the
/employers/save-without-image
endpoint.Your feedback on this fix and any suggestions for further improvement are highly appreciated.
Best regards,
Pramitha Jauasooriya Backend Developer at LifePill