Skip to content

Commit

Permalink
recalculate due date when creation date is adjusted. close #2252
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Jan 3, 2024
1 parent c19d0f3 commit dd4e7eb
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ You should also get your employer (if you work as a programmer) or school,
import java.awt.event.ActionEvent;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
Expand Down Expand Up @@ -1837,6 +1839,20 @@ private void cmdConfirmInvoiceNumberActionPerformed(java.awt.event.ActionEvent e
private void cmdDateCreatedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDateCreatedActionPerformed
MultiCalDialog dlg = new MultiCalDialog(this.dtCreated, EditorsRegistry.getInstance().getMainWindow(), true);
dlg.setVisible(true);

try {
Date paymentDate=df.parse(this.dtCreated.getText());
int dueInDays=this.invoicePools.get(this.cmbInvoicePool.getSelectedItem().toString()).getPaymentTerm();

LocalDateTime localDateTime = paymentDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
localDateTime = localDateTime.plusDays(dueInDays);
paymentDate = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
this.dtDue.setText(df.format(paymentDate));

} catch (Throwable t) {
log.error("Cannot recalculate due date for creation date " + this.dtCreated.getText());
}

}//GEN-LAST:event_cmdDateCreatedActionPerformed

private void cmdDatePeriodFromActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDatePeriodFromActionPerformed
Expand Down

0 comments on commit dd4e7eb

Please sign in to comment.