org.notima.businessobjects.adapter.sie.SieAdapter Maven / Gradle / Ivy
The newest version!
package org.notima.businessobjects.adapter.sie;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.notima.generic.businessobjects.AccountingVoucher;
import org.notima.generic.businessobjects.BasicBusinessObjectFactory;
import org.notima.generic.businessobjects.BusinessPartner;
import org.notima.generic.businessobjects.BusinessPartnerList;
import org.notima.generic.businessobjects.DunningRun;
import org.notima.generic.businessobjects.Invoice;
import org.notima.generic.businessobjects.Order;
import org.notima.generic.businessobjects.PaymentTerm;
import org.notima.generic.businessobjects.PriceList;
import org.notima.generic.businessobjects.Product;
import org.notima.generic.businessobjects.ProductCategory;
import org.notima.generic.businessobjects.Tax;
import org.notima.generic.ifacebusinessobjects.FactoringReservation;
import org.notima.sie.SIEFileType4;
import org.notima.sie.SIEUtil;
import org.notima.sie.VerRec;
public class SieAdapter extends BasicBusinessObjectFactory<
Object,
Object,
Object,
Object,
Object,
Object> {
public static final String SYSTEM_NAME = "SIE";
public static final String PROP_SIE_FILE_PATH = "SieFilePath";
public static final String PROP_SIE_FILE_PREFIX = "SieFilePrefix";
@Override
public String getSystemName() {
return SYSTEM_NAME;
}
@Override
public List writeVouchers(List vouchers) throws Exception {
String destinationPath = this.getSetting(PROP_SIE_FILE_PATH);
String filePrefix = this.getSetting(PROP_SIE_FILE_PREFIX);
if (filePrefix==null) {
filePrefix = "";
}
if (destinationPath==null) {
destinationPath = System.getProperty("user.home") + File.separator + filePrefix + "SIE4.si";
}
if (!destinationPath.toUpperCase().endsWith(".SI")) {
if (!destinationPath.endsWith(File.separator))
destinationPath += File.separator;
destinationPath += filePrefix + "SIE4.si";
}
SIEFileType4 sie4file = new SIEFileType4(destinationPath);
BusinessPartner> tenant = getCurrentTenant();
if (tenant!=null) {
if (tenant.getTaxId()!=null)
sie4file.setOrgNr(tenant.getTaxId());
if (tenant.getName()!=null)
sie4file.setFNamn(tenant.getName());
}
sie4file.setProgram(SIEUtil.SIEFileLibString);
VerRec vr;
for (AccountingVoucher v : vouchers) {
vr = SieConverter.convert(v);
sie4file.addVerRecord(vr);
}
sie4file.writeToFile();
return vouchers;
}
@Override
public BusinessPartnerList