Skip to content

Commit

Permalink
[26486] use double for amount, leave scale factor2 to billing impl
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Jan 15, 2025
1 parent e85ae54 commit 8efa56f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ private void changePriceLeistung(Object item) {
acquireLock(locks, verrechnet, false);
int tp = leistungDTO.getTp();
int tpOld = verrechnet.getPoints();
verrechnet.setSecondaryScale((int) (leistungDTO.getScale2() * 100));
if (tpOld != tp) {
verrechnet.setPoints(tp);
log.debug("invoice correction: price changed to [{}] for leistung id [{}]",
Expand All @@ -733,7 +732,6 @@ private void changeCountLeistung(Object item) {
IStatus ret = BillingServiceHolder.get().changeAmountValidated(verrechnet, leistungDTO.getCount());
log.debug("invoice correction: changed count from leistung id [{}]", leistungDTO.getId());
if (ret.isOK()) {
verrechnet.setSecondaryScale((int) (leistungDTO.getScale2() * 100));
CoreModelServiceHolder.get().save(verrechnet);
} else {
addToOutput(output, ret.getMessage());
Expand Down Expand Up @@ -831,7 +829,6 @@ private void transferLeistungen(Object base, Object item, Object additional) {
log.debug("invoice correction: count changed from [{}] to {[]} - for leistung id [{}]",
itemLeistung.getId());
if (ret.isOK()) {
verrechnet.setSecondaryScale((int) (itemLeistung.getScale2() * 100));
CoreModelServiceHolder.get().save(verrechnet);
} else {
verrechnet = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ public class LeistungDTO {
private final String id;
private String code;
private final String text;
private int count;
private double count;
private IBillable iVerrechenbar;
private long lastUpdate;
private IBilled verrechnet;

private int tp = 0;
private double tpw = 1.0;
private double scale1 = 1.0;
private double scale2 = 1.0;

public LeistungDTO(Verrechnet verrechnet) throws ElexisException {

Expand All @@ -54,7 +53,7 @@ public LeistungDTO(Verrechnet verrechnet) throws ElexisException {
this.text = verrechnet.getText();
this.tp = this.verrechnet.getPoints();
this.tpw = this.verrechnet.getFactor();
this.count = verrechnet.getZahl();
this.count = this.verrechnet.getAmount();
this.iVerrechenbar = this.verrechnet.getBillable();
}

Expand All @@ -66,7 +65,6 @@ public LeistungDTO(IBillable iVerrechenbar, IFall fall) {
this.tp = -1;
this.tpw = 1.0;
this.scale1 = 1.0;
this.scale2 = 1.0;
this.count = 1;
this.iVerrechenbar = iVerrechenbar;
}
Expand All @@ -80,7 +78,6 @@ public boolean calcPrice(KonsultationDTO konsultationDTO, FallDTO fallDTO, Consu
tp = result.get().getPoints();
tpw = result.get().getFactor();
scale1 = result.get().getPrimaryScaleFactor();
scale2 = result.get().getSecondaryScaleFactor();
} else {
LoggerFactory.getLogger(getClass()).warn("Adding billable failed [" + result.getMessages() + "]");
showResult.accept(result);
Expand All @@ -89,7 +86,6 @@ public boolean calcPrice(KonsultationDTO konsultationDTO, FallDTO fallDTO, Consu
} else {
tpw = getFactor();
scale1 = verrechnet.getPrimaryScaleFactor();
scale2 = verrechnet.getSecondaryScaleFactor();
}
return true;
}
Expand All @@ -109,14 +105,6 @@ public void setTp(int tp) {
this.tp = tp;
}

public void setScale2(double scale2) {
this.scale2 = scale2;
}

public double getScale2() {
return scale2;
}

public IBilled getVerrechnet() {
return verrechnet;
}
Expand All @@ -142,14 +130,14 @@ public String getId() {
}

public Money getPrice() {
return new Money((int) (Math.round(tp * tpw) * scale1 * scale2 * count));
return new Money((int) (Math.round(tp * tpw) * scale1 * count));
}

public void setCount(int count) {
public void setCount(double count) {
this.count = count;
}

public int getCount() {
public double getCount() {
return count;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,9 @@ private boolean changePriceDialog(LeistungDTO leistungDTO) {
val = val.substring(0, val.length() - 1);
double percent = Double.parseDouble(val);
double scaleFactor = 1.0 + (percent / 100.0);
leistungDTO.setScale2(scaleFactor);
customPrice = leistungDTO.getPrice();
customPrice = leistungDTO.getPrice().multiply(scaleFactor);
} else {
customPrice = new Money(val);
leistungDTO.setScale2(Double.valueOf(1));
}
if (customPrice != null) {
leistungDTO.setTp(customPrice.getCents());
Expand All @@ -1434,35 +1432,31 @@ private boolean changePriceDialog(LeistungDTO leistungDTO) {
}

private boolean changeQuantityDialog(LeistungDTO leistungDTO) {
String p = Integer.toString(leistungDTO.getCount());
String p = Double.toString(leistungDTO.getCount());
InputDialog dlg = new InputDialog(UiDesk.getTopShell(), Messages.VerrechnungsDisplay_changeNumberCaption, // $NON-NLS-1$
Messages.VerrechnungsDisplay_changeNumberBody, // $NON-NLS-1$
p, null);
if (dlg.open() == Dialog.OK) {
try {
String val = dlg.getValue();
if (!StringTool.isNothing(val)) {
int changeAnzahl;
double secondaryScaleFactor = 1.0;
double changeAnzahl = 1.0;
String text = leistungDTO.getIVerrechenbar().getText();

if (val.indexOf(StringConstants.SLASH) > 0) {
changeAnzahl = 1;
String[] frac = val.split(StringConstants.SLASH);
secondaryScaleFactor = Double.parseDouble(frac[0]) / Double.parseDouble(frac[1]);
changeAnzahl = Double.parseDouble(frac[0]) / Double.parseDouble(frac[1]);
text = leistungDTO.getIVerrechenbar().getText() + " (" + val //$NON-NLS-1$
+ Messages.VerrechnungsDisplay_Orininalpackungen;
} else if (val.indexOf('.') > 0) {
changeAnzahl = 1;
secondaryScaleFactor = Double.parseDouble(val);
text = leistungDTO.getIVerrechenbar().getText() + " (" + Double.toString(secondaryScaleFactor) //$NON-NLS-1$
changeAnzahl = Double.parseDouble(val);
text = leistungDTO.getIVerrechenbar().getText() + " (" + Double.toString(changeAnzahl) //$NON-NLS-1$
+ ")"; //$NON-NLS-1$
} else {
changeAnzahl = Integer.parseInt(dlg.getValue());
changeAnzahl = Double.parseDouble(val);
}

leistungDTO.setCount(changeAnzahl);
leistungDTO.setScale2(secondaryScaleFactor);
return true;
}
} catch (NumberFormatException ne) {
Expand All @@ -1479,7 +1473,7 @@ private void releaseAndRefreshLock(IPersistentObject object, String commandId) {
if (object != null && LocalLockServiceHolder.get().isLocked(object)) {
LocalLockServiceHolder.get().releaseLock(object);
}
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
commandService.refreshElements(commandId, null);
}

Expand Down

0 comments on commit 8efa56f

Please sign in to comment.