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;