seperate sequences (invoices - stock Moves)

This commit is contained in:
2023-01-18 08:24:36 +01:00
parent 039a38f0f7
commit 11e5cad88f
12 changed files with 207 additions and 23 deletions

View File

@@ -74,7 +74,7 @@ public class InvoiceManagementRepository extends InvoiceRepository {
public Invoice save(Invoice invoice) {
try {
invoice = super.save(invoice);
Beans.get(InvoiceService.class).setDraftSequence(invoice);
Beans.get(InvoiceService.class).setSequence(invoice);
return invoice;
} catch (Exception e) {

View File

@@ -550,6 +550,31 @@ public class AccountConfigService {
return accountConfig.getCustRefSequence();
}
// ff
public Sequence getFinancialCustInvSequence(AccountConfig accountConfig) throws AxelorException {
if (accountConfig.getFinancialCustInvSequence() == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.ACCOUNT_CONFIG_SEQUENCE_2),
I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION),
accountConfig.getCompany().getName());
}
return accountConfig.getFinancialCustInvSequence();
}
// AVR
public Sequence getFinancialCustRefSequence(AccountConfig accountConfig) throws AxelorException {
if (accountConfig.getFinancialCustRefSequence() == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.ACCOUNT_CONFIG_SEQUENCE_2),
I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION),
accountConfig.getCompany().getName());
}
return accountConfig.getFinancialCustRefSequence();
}
public Sequence getSuppInvSequence(AccountConfig accountConfig) throws AxelorException {
if (accountConfig.getSuppInvSequence() == null) {

View File

@@ -148,6 +148,8 @@ public interface InvoiceService {
public void setDraftSequence(Invoice invoice) throws AxelorException;
public void setSequence(Invoice invoice) throws AxelorException;
public Invoice mergeInvoiceProcess(
List<Invoice> invoiceList,
Company company,

View File

@@ -52,6 +52,7 @@ import com.axelor.apps.base.db.Company;
import com.axelor.apps.base.db.Currency;
import com.axelor.apps.base.db.Partner;
import com.axelor.apps.base.db.PriceList;
import com.axelor.apps.base.db.Sequence;
import com.axelor.apps.base.db.repo.BankDetailsRepository;
import com.axelor.apps.base.db.repo.PriceListRepository;
import com.axelor.apps.base.service.PartnerService;
@@ -440,6 +441,48 @@ public class InvoiceServiceImpl extends InvoiceRepository implements InvoiceServ
}
}
@Override
public void setSequence(Invoice invoice) throws AxelorException {
if (invoice.getId() != null && Strings.isNullOrEmpty(invoice.getInvoiceId())) {
invoice.setInvoiceId(Beans.get(SequenceService.class).getSequenceNumber(getSequence(invoice), Beans.get(AppBaseService.class).getTodayDate()));
}
}
protected Sequence getSequence(Invoice invoice) throws AxelorException {
AccountConfig accountConfig = accountConfigService.getAccountConfig(invoice.getCompany());
switch (invoice.getOperationTypeSelect()) {
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE:
return accountConfigService.getSuppInvSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND:
return accountConfigService.getSuppRefSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE:
if(invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_FINANCIAL_DISCOUNT){
return accountConfigService.getFinancialCustInvSequence(accountConfig);
}else{
return accountConfigService.getCustInvSequence(accountConfig);
}
case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND:
if(invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_FINANCIAL_REFUNDS){
return accountConfigService.getFinancialCustRefSequence(accountConfig);
}else{
return accountConfigService.getCustRefSequence(accountConfig);
}
default:
throw new AxelorException(
invoice,
TraceBackRepository.CATEGORY_MISSING_FIELD,
I18n.get(IExceptionMessage.JOURNAL_1),
invoice.getInvoiceId());
}
}
public Invoice mergeInvoiceProcess(
List<Invoice> invoiceList,
Company company,

View File

@@ -319,10 +319,17 @@ public class VentilateState extends WorkflowInvoice {
return accountConfigService.getSuppRefSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE:
if(invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_FINANCIAL_DISCOUNT){
return accountConfigService.getFinancialCustInvSequence(accountConfig);
}else{
return accountConfigService.getCustInvSequence(accountConfig);
}
case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND:
return accountConfigService.getCustRefSequence(accountConfig);
if(invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_FINANCIAL_REFUNDS){
return accountConfigService.getFinancialCustRefSequence(accountConfig);
}else{
return accountConfigService.getCustRefSequence(accountConfig);
}
default:
throw new AxelorException(

View File

@@ -133,7 +133,9 @@
<!-- Sequence -->
<many-to-one name="custInvSequence" ref="com.axelor.apps.base.db.Sequence" title="Customer invoices sequence"/>
<many-to-one name="financialCustInvSequence" ref="com.axelor.apps.base.db.Sequence" title="Financial Customer invoices sequence"/>
<many-to-one name="custRefSequence" ref="com.axelor.apps.base.db.Sequence" title="Customer refunds sequence"/>
<many-to-one name="financialCustRefSequence" ref="com.axelor.apps.base.db.Sequence" title="Financial Customer refunds sequence"/>
<many-to-one name="suppInvSequence" ref="com.axelor.apps.base.db.Sequence" title="Supplier invoices sequence"/>
<many-to-one name="suppRefSequence" ref="com.axelor.apps.base.db.Sequence" title="Supplier refunds sequence"/>

View File

@@ -181,6 +181,10 @@
public static final int OPERATION_SUB_TYPE_DEFAULT = 1;
public static final int OPERATION_SUB_TYPE_ADVANCE = 2;
public static final int OPERATION_SUB_TYPE_BALANCE = 3;
public static final int OPERATION_SUB_TYPE_FINANCIAL_DISCOUNT = 9;
public static final int OPERATION_SUB_TYPE_FINANCIAL_REFUNDS = 10;
// REPORT TYPE
public static final int REPORT_TYPE_PROFORMA = 1;

View File

@@ -287,9 +287,24 @@ public class StockMoveServiceImpl implements StockMoveService {
if (Beans.get(SequenceService.class)
.isEmptyOrDraftSequenceNumber(stockMove.getStockMoveSeq())) {
draftSeq = stockMove.getStockMoveSeq();
stockMove.setStockMoveSeq(
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING && stockMove.getIsReversion() == true){
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() != 853 ){
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
} else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() == 853){
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT, stockMove.getCompany()));
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == true){
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
}
else{
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
stockMove.getTypeSelect(), stockMove.getCompany()));
}
} else {
draftSeq = null;
}
@@ -632,6 +647,24 @@ public class StockMoveServiceImpl implements StockMoveService {
stockMoveLines = MoreObjects.firstNonNull(stockMoveLines, Collections.emptyList());
StockMove newStockMove = stockMoveRepo.copy(stockMove, false);
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING && stockMove.getIsReversion() == true){
stockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
}else{
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
newStockMove.getTypeSelect(), newStockMove.getCompany()));
}
newStockMove.setName(
stockMoveToolService.computeName(
newStockMove,
newStockMove.getStockMoveSeq()
+ " "
+ I18n.get(IExceptionMessage.STOCK_MOVE_7)
+ " "
+ stockMove.getStockMoveSeq()
+ " )"));
// In copy OriginTypeSelect set null.
newStockMove.setOriginTypeSelect(stockMove.getOriginTypeSelect());
for (StockMoveLine stockMoveLine : stockMoveLines) {
@@ -647,18 +680,7 @@ public class StockMoveServiceImpl implements StockMoveService {
}
newStockMove.setRealDate(null);
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
newStockMove.getTypeSelect(), newStockMove.getCompany()));
newStockMove.setName(
stockMoveToolService.computeName(
newStockMove,
newStockMove.getStockMoveSeq()
+ " "
+ I18n.get(IExceptionMessage.STOCK_MOVE_7)
+ " "
+ stockMove.getStockMoveSeq()
+ " )"));
newStockMove.setExTaxTotal(stockMoveToolService.compute(newStockMove));
plan(newStockMove);
@@ -714,9 +736,15 @@ public class StockMoveServiceImpl implements StockMoveService {
newStockMove.setTypeSelect(StockMoveRepository.TYPE_INCOMING);
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INTERNAL)
newStockMove.setTypeSelect(StockMoveRepository.TYPE_INTERNAL);
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
newStockMove.getTypeSelect(), newStockMove.getCompany()));
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false){
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));}
else{
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
newStockMove.getTypeSelect(), newStockMove.getCompany()));
}
for (StockMoveLine stockMoveLine : stockMoveLines) {
@@ -739,9 +767,9 @@ public class StockMoveServiceImpl implements StockMoveService {
return Optional.empty();
}
newStockMove.setStockMoveSeq(
stockMoveToolService.getSequenceStockMove(
newStockMove.getTypeSelect(), newStockMove.getCompany()));
// newStockMove.setStockMoveSeq(
// stockMoveToolService.getSequenceStockMove(
// newStockMove.getTypeSelect(), newStockMove.getCompany()));
newStockMove.setName(
stockMoveToolService.computeName(
newStockMove,

View File

@@ -129,6 +129,47 @@ public class StockMoveToolServiceImpl implements StockMoveToolService {
}
break;
case StockMoveRepository.TYPE_INCOMING_CLIENT:
ref = sequenceService.getSequenceNumber(SequenceRepository.INCOMING_CLIENT, company);
if (ref == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.STOCK_MOVE_3),
company.getName());
}
break;
case StockMoveRepository.TYPE_OUTGOING_CLIENT:
ref = sequenceService.getSequenceNumber(SequenceRepository.OUTGOING_CLIENT, company);
if (ref == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.STOCK_MOVE_3),
company.getName());
}
break;
case StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT:
ref = sequenceService.getSequenceNumber(SequenceRepository.CUST_DELIVERY, company);
if (ref == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.STOCK_MOVE_3),
company.getName());
}
break;
case StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT:
ref = sequenceService.getSequenceNumber(SequenceRepository.SUP_RETURN, company);
if (ref == null) {
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
I18n.get(IExceptionMessage.STOCK_MOVE_3),
company.getName());
}
break;
default:
throw new AxelorException(
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,

View File

@@ -14,6 +14,13 @@
public static final String INTERNAL = "intStockMove";
public static final String OUTGOING = "outStockMove";
public static final String INCOMING = "inStockMove";
public static final String INCOMING_CLIENT = "customerReturn";
public static final String OUTGOING_CLIENT = "clientDelivery";
//sortie de stock
public static final String CUST_DELIVERY = "internalDelivery";
//retour fournisseur
public static final String SUP_RETURN = "supReturn";
public static final String PRODUCT_TRACKING_NUMBER = "productTrackingNumber";
public static final String LOGISTICAL_FORM = "logisticalForm";

View File

@@ -123,6 +123,14 @@
public static final int TYPE_INTERNAL = 1;
public static final int TYPE_OUTGOING = 2;
public static final int TYPE_INCOMING = 3;
// client return
public static final int TYPE_INCOMING_CLIENT = 4;
// client delivery
public static final int TYPE_OUTGOING_CLIENT = 5;
// internal delivery
public static final int TYPE_INTERNAL_OUTGOING_CLIENT = 6;
// supplier return
public static final int TYPE_SUPPLIER_OUTGOING_CLIENT = 7;
// CONFORMITY SELECT
public static final int CONFORMITY_NONE = 1;

View File

@@ -571,8 +571,25 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
AccountConfigService accountConfigService = Beans.get(AccountConfigService.class);
AccountConfig accountConfig = accountConfigService.getAccountConfig(invoice.getCompany());
switch (invoice.getOperationTypeSelect()) {
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE:
return accountConfigService.getSuppInvSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND:
return accountConfigService.getSuppRefSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE:
return accountConfigService.getCustInvSequence(accountConfig);
case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND:
return accountConfigService.getCustRefSequence(accountConfig);
default:
throw new AxelorException(
invoice,
TraceBackRepository.CATEGORY_MISSING_FIELD,
I18n.get("Invoice type missing %s"),
invoice.getInvoiceId());
}
}
}