public void documentSetPayrollConfiguration()

in component-test/src/main/java/org/apache/fineract/cn/payroll/PayrollApiDocumentation.java [89:131]


  public void documentSetPayrollConfiguration ( ) throws Exception {

    final PayrollConfiguration payrollConfiguration = DomainObjectGenerator.getPayrollConfiguration();
    payrollConfiguration.setMainAccountNumber("12345678910");

    final PayrollAllocation savingsAllocation = new PayrollAllocation();
    savingsAllocation.setAccountNumber("9876543210");
    savingsAllocation.setAmount(BigDecimal.valueOf(5500.00D));
    savingsAllocation.setProportional(Boolean.TRUE);

    final PayrollAllocation tradeUnionAllocation = new PayrollAllocation();
    tradeUnionAllocation.setAccountNumber("24681097531");
    tradeUnionAllocation.setAmount(BigDecimal.valueOf(43.00D));
    tradeUnionAllocation.setProportional(Boolean.TRUE);

    final ArrayList <PayrollAllocation> payrollAllocations = new ArrayList <>();
    payrollConfiguration.setPayrollAllocations(payrollAllocations);
    payrollAllocations.add(savingsAllocation);
    payrollAllocations.add(tradeUnionAllocation);

    final Customer customer = new Customer();
    customer.setIdentifier("customerOne");

    this.prepareConfigurationMocks(customer.getIdentifier(), payrollConfiguration);

    Gson gson = new Gson();
    this.mockMvc.perform(put("/customers/" + customer.getIdentifier() + "/payroll")
            .accept(MediaType.APPLICATION_JSON_VALUE)
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .content(gson.toJson(payrollConfiguration)))
            .andExpect(status().isAccepted())
            .andDo(document("document-set-payroll-configuration", preprocessRequest(prettyPrint()),
                    requestFields(
                            fieldWithPath("mainAccountNumber").description("Main account number"),
                            fieldWithPath("payrollAllocations[].accountNumber").description("Account from where you pay first allocation"),
                            fieldWithPath("payrollAllocations[].amount").type("Integer").description("Amount to be paid during first allocation"),
                            fieldWithPath("payrollAllocations[].proportional").type("Boolean").description("Should payments be proportional ?"),
                            fieldWithPath("payrollAllocations[1].accountNumber").description("Account from where you pay second allocation"),
                            fieldWithPath("payrollAllocations[1].amount").type("Integer").description("Amount to be paid during first allocation"),
                            fieldWithPath("payrollAllocations[1].proportional").type("Boolean").description("Should payments be proportional ?")
                    )
            ));
  }