Search in sources :

Example 1 with SopLine

use of com.axelor.apps.production.db.SopLine in project axelor-open-suite by axelor.

the class SopServiceImpl method linkSOPLines.

@Transactional
protected void linkSOPLines(Sop sop, List<SopLine> sopLineList) {
    sop = sopRepo.find(sop.getId());
    sop.clearSopLineList();
    for (SopLine sopLine : sopLineList) {
        sop.addSopLineListItem(sopLine);
    }
    sop.setIsGenerated(true);
    sopRepo.save(sop);
}
Also used : SopLine(com.axelor.apps.production.db.SopLine) Transactional(com.google.inject.persist.Transactional)

Example 2 with SopLine

use of com.axelor.apps.production.db.SopLine in project axelor-open-suite by axelor.

the class SopServiceImpl method createSOPLine.

protected SopLine createSOPLine(Sop sop, Period period) {
    SopLine sopLine = new SopLine();
    sopLine.setPeriod(period);
    sopLine.setYear(period.getYear());
    sopLine.setCurrency(sop.getCompany().getCurrency());
    sop.addSopLineListItem(sopLine);
    return sopLine;
}
Also used : SopLine(com.axelor.apps.production.db.SopLine)

Example 3 with SopLine

use of com.axelor.apps.production.db.SopLine in project axelor-open-suite by axelor.

the class SopServiceImpl method generateSOPLines.

@Override
public void generateSOPLines(Sop sop) throws AxelorException {
    today = appBaseService.getTodayDate(sop.getCompany());
    List<Period> yearPeriods = periodRepo.all().filter("self.year = :year AND self.statusSelect = :status").bind("year", sop.getYear()).bind("status", PeriodRepository.STATUS_OPENED).fetch();
    List<SopLine> sopLineList = new ArrayList<SopLine>();
    for (Period period : yearPeriods) {
        sopLineList.add(this.createSOPLine(sop, period));
    }
    this.linkSOPLines(sop, sopLineList);
    this.updateSOPLines(sop);
}
Also used : SopLine(com.axelor.apps.production.db.SopLine) ArrayList(java.util.ArrayList) Period(com.axelor.apps.base.db.Period)

Aggregations

SopLine (com.axelor.apps.production.db.SopLine)3 Period (com.axelor.apps.base.db.Period)1 Transactional (com.google.inject.persist.Transactional)1 ArrayList (java.util.ArrayList)1