New version of services
This commit is contained in:
parent
37dc0a7571
commit
55b76bb1a7
|
|
@ -6,16 +6,6 @@ import tk.artikus.assets.AssetLife;
|
|||
import tk.artikus.assets.AssetLifeChange;
|
||||
import tk.artikus.assets.tools.YearMonth;
|
||||
|
||||
class Convert{
|
||||
static long txtToLong( String value ) {
|
||||
value = value.replace( ",", "" );
|
||||
float fInitial = Float.parseFloat( value );
|
||||
long lValue = (long) (fInitial * 100);
|
||||
return lValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
record YearMonthFromAngular(int year, int month) {
|
||||
YearMonth toYearMonth() {
|
||||
|
|
@ -23,6 +13,21 @@ record YearMonthFromAngular(int year, int month) {
|
|||
}
|
||||
}
|
||||
|
||||
record AssetDepreciationMethodFromAngular( String year, AssetDepreciationMethod.Type type, String factor, String rate ) {
|
||||
AssetDepreciationMethod toAssetDepreciationMethod(){
|
||||
return AssetDepreciationMethod.builder()
|
||||
.type( type )
|
||||
.factor( 0, Convert.txtToLong( factor ) )
|
||||
.rate( 0, Convert.txtToLong( rate ) )
|
||||
.build();
|
||||
}
|
||||
|
||||
int getYear() {
|
||||
return (int)Convert.txtToInt( year );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
record AssetLifeChangeFromAngular(YearMonthFromAngular when, String initial, String residual, String depreciation) {
|
||||
AssetLifeChange toAssetLifeChange( boolean isFirst ) {
|
||||
|
||||
|
|
@ -38,12 +43,23 @@ record AssetLifeChangeFromAngular(YearMonthFromAngular when, String initial, Str
|
|||
}
|
||||
}
|
||||
|
||||
class Convert{
|
||||
static long txtToLong( String value ) {
|
||||
value = value.replace( ",", "" );
|
||||
float fInitial = Float.parseFloat( value );
|
||||
long lValue = (long) (fInitial * 100);
|
||||
return lValue;
|
||||
}
|
||||
static int txtToInt( String value ) {
|
||||
return Integer.valueOf( value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public record AssetFromAngular(
|
||||
YearMonthFromAngular start,
|
||||
String depreciationRate,
|
||||
AssetDepreciationMethod.Type type,
|
||||
String factorValue,
|
||||
AssetLifeChangeFromAngular[] life) {
|
||||
AssetLifeChangeFromAngular[] life,
|
||||
AssetDepreciationMethodFromAngular[] depreciationMethods) {
|
||||
|
||||
Asset toAsset() {
|
||||
|
||||
|
|
@ -53,12 +69,10 @@ public record AssetFromAngular(
|
|||
YearMonth start = this.start.toYearMonth();
|
||||
asset.setStartOfDepreciation( start );
|
||||
|
||||
long lDepreciation = Convert.txtToLong( depreciationRate );
|
||||
long lFactor = Convert.txtToLong( factorValue );
|
||||
AssetDepreciationMethod assetDepreciationMethod = AssetDepreciationMethod.builder().type( type )
|
||||
.factor( 0, lFactor ).rate( 0, lDepreciation ).build();
|
||||
|
||||
asset.setFromYearDepreciationMethod( start.getYear(), assetDepreciationMethod );
|
||||
for( AssetDepreciationMethodFromAngular depreciationMethodFromAngular : depreciationMethods ) {
|
||||
asset.setFromYearDepreciationMethod(depreciationMethodFromAngular.getYear(),
|
||||
depreciationMethodFromAngular.toAssetDepreciationMethod() );
|
||||
}
|
||||
|
||||
|
||||
AssetLife assetLife = new AssetLife();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package tk.artikus.assets.services;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
|
|
|||
Loading…
Reference in New Issue