use of com.axelor.apps.account.db.FixedAsset in project axelor-open-suite by axelor.
the class FixedAssetController method computeDepreciation.
public void computeDepreciation(ActionRequest request, ActionResponse response) {
FixedAsset fixedAsset = request.getContext().asType(FixedAsset.class);
try {
if (fixedAsset.getGrossValue().compareTo(BigDecimal.ZERO) > 0) {
if (!fixedAsset.getFixedAssetLineList().isEmpty()) {
fixedAsset.getFixedAssetLineList().clear();
}
fixedAsset = Beans.get(FixedAssetService.class).generateAndComputeLines(fixedAsset);
} else {
fixedAsset.getFixedAssetLineList().clear();
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setValue("residualValue", fixedAsset.getGrossValue());
response.setValue("fixedAssetLineList", fixedAsset.getFixedAssetLineList());
}
use of com.axelor.apps.account.db.FixedAsset in project axelor-open-suite by axelor.
the class FixedAssetController method createAnalyticDistributionWithTemplate.
public void createAnalyticDistributionWithTemplate(ActionRequest request, ActionResponse response) {
try {
FixedAsset fixedAsset = request.getContext().asType(FixedAsset.class);
Beans.get(FixedAssetService.class).updateAnalytic(fixedAsset);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.FixedAsset in project axelor-open-suite by axelor.
the class TestFixedAssetLineComputationService method testComputePlannedFixedAssetLineWithProrata.
@Test
public void testComputePlannedFixedAssetLineWithProrata() {
FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(false), new BigDecimal("500.00"));
FixedAssetLine firstFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("23.89"), new BigDecimal("23.89"), new BigDecimal("476.11"));
FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, firstFixedAssetLine);
assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("100.00"), new BigDecimal("123.89"), new BigDecimal("376.11")), fixedAssetLine);
}
use of com.axelor.apps.account.db.FixedAsset in project axelor-open-suite by axelor.
the class TestFixedAssetLineComputationService method testComputeOngoingDegressiveAssetLine.
@Test
public void testComputeOngoingDegressiveAssetLine() {
FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_DEGRESSIVE, new BigDecimal("1.75"), LocalDate.of(2020, 3, 31), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(true, false), new BigDecimal("20000.00"));
FixedAssetLine previousFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("5250.00"), new BigDecimal("5250.00"), new BigDecimal("14750.00"));
fixedAsset.addFixedAssetLineListItem(previousFixedAssetLine);
FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, previousFixedAssetLine);
assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("5162.50"), new BigDecimal("10412.50"), new BigDecimal("9587.50")), fixedAssetLine);
}
use of com.axelor.apps.account.db.FixedAsset in project axelor-open-suite by axelor.
the class TestFixedAssetLineComputationService method testComputePlannedFixedAssetLineWithoutProrata.
@Test
public void testComputePlannedFixedAssetLineWithoutProrata() {
FixedAsset fixedAsset = createFixedAsset(FixedAssetRepository.COMPUTATION_METHOD_LINEAR, LocalDate.of(2020, 10, 4), LocalDate.of(2020, 12, 31), 5, 12, createFixedAssetCategoryFromIsProrataTemporis(false), new BigDecimal("500.00"));
FixedAssetLine firstFixedAssetLine = createFixedAssetLine(LocalDate.of(2020, 12, 31), new BigDecimal("100.00"), new BigDecimal("100.00"), new BigDecimal("400.00"));
FixedAssetLine fixedAssetLine = fixedAssetLineComputationService.computePlannedFixedAssetLine(fixedAsset, firstFixedAssetLine);
assertFixedAssetLineEquals(createFixedAssetLine(LocalDate.of(2021, 12, 31), new BigDecimal("100.00"), new BigDecimal("200.00"), new BigDecimal("300.00")), fixedAssetLine);
}
Aggregations