com.mindee.product.fr.payslip.PayslipV2SalaryDetail Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mindee-api-java Show documentation
Show all versions of mindee-api-java Show documentation
Java Library to call Mindee's Off-The-Shelf and Custom APIs
The newest version!
package com.mindee.product.fr.payslip;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mindee.parsing.SummaryHelper;
import com.mindee.parsing.standard.BaseField;
import com.mindee.parsing.standard.LineItemField;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
/**
* Detailed information about the earnings.
*/
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class PayslipV2SalaryDetail extends BaseField implements LineItemField {
/**
* The amount of the earnings.
*/
@JsonProperty("amount")
Double amount;
/**
* The base value of the earnings.
*/
@JsonProperty("base")
Double base;
/**
* The description of the earnings.
*/
@JsonProperty("description")
String description;
/**
* The rate of the earnings.
*/
@JsonProperty("rate")
Double rate;
public boolean isEmpty() {
return (
amount == null
&& base == null
&& (description == null || description.isEmpty())
&& rate == null
);
}
private Map tablePrintableValues() {
Map printable = new HashMap<>();
printable.put(
"amount",
SummaryHelper.formatAmount(this.amount)
);
printable.put(
"base",
SummaryHelper.formatAmount(this.base)
);
printable.put("description", SummaryHelper.formatForDisplay(this.description, 36));
printable.put(
"rate",
SummaryHelper.formatAmount(this.rate)
);
return printable;
}
/**
* Output the line in a format suitable for inclusion in an rST table.
*/
public String toTableLine() {
Map printable = this.tablePrintableValues();
return String.format("| %-12s ", printable.get("amount"))
+ String.format("| %-9s ", printable.get("base"))
+ String.format("| %-36s ", printable.get("description"))
+ String.format("| %-9s |", printable.get("rate"));
}
@Override
public String toString() {
Map printable = this.printableValues();
return String.format("Amount: %s", printable.get("amount"))
+ String.format(", Base: %s", printable.get("base"))
+ String.format(", Description: %s", printable.get("description"))
+ String.format(", Rate: %s", printable.get("rate"));
}
private Map printableValues() {
Map printable = new HashMap<>();
printable.put(
"amount",
SummaryHelper.formatAmount(this.amount)
);
printable.put(
"base",
SummaryHelper.formatAmount(this.base)
);
printable.put("description", SummaryHelper.formatForDisplay(this.description, null));
printable.put(
"rate",
SummaryHelper.formatAmount(this.rate)
);
return printable;
}
}