This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38ff744
commit d6a5a3b
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/net/collaud/fablab/manager/export/custom/CsvExporterAccounting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.collaud.fablab.manager.export.custom; | ||
|
||
import net.collaud.fablab.manager.export.*; | ||
import java.lang.reflect.Field; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.collaud.fablab.manager.data.virtual.HistoryEntry; | ||
|
||
/** | ||
* | ||
* @author Gaetan Collaud | ||
* @param <T> | ||
*/ | ||
@Slf4j | ||
public class CsvExporterAccounting extends CsvExporter<HistoryEntry>{ | ||
|
||
public static final String FIELD_TO_OVERRIDE = "amount"; | ||
|
||
public CsvExporterAccounting() { | ||
super(HistoryEntry.class); | ||
} | ||
|
||
@Override | ||
public String postHeader(String header){ | ||
return header.replace(FIELD_TO_OVERRIDE, "credit"+FIELD_SEPARATOR+"debit"); | ||
} | ||
|
||
@Override | ||
protected String getFieldValue(HistoryEntry obj, Field f) { | ||
String parsed = super.getFieldValue(obj, f); | ||
if(f.getAnnotation(CsvField.class).headerName().equals(FIELD_TO_OVERRIDE)){ | ||
Double v = obj.getAmount(); | ||
if(v<0){ | ||
return FIELD_SEPARATOR+Double.toString(-v); | ||
}else{ | ||
return parsed+FIELD_SEPARATOR; | ||
} | ||
} | ||
return parsed; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters