提交 810a00ea 编写于 作者: yujiaming's avatar yujiaming

自定义Purchase_order的button_cancel,button_done, button_unlock行为

上级 cd7c83e8
package cn.ibizlab.businesscentral.core.extensions.service; package cn.ibizlab.businesscentral.core.extensions.service;
import cn.ibizlab.businesscentral.core.odoo_account.domain.Account_move;
import cn.ibizlab.businesscentral.core.odoo_account.service.impl.Account_moveServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_currency;
import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_partner;
import cn.ibizlab.businesscentral.core.odoo_base.service.impl.Res_partnerServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_product;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_supplierinfo;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_template;
import cn.ibizlab.businesscentral.core.odoo_product.service.impl.Product_productServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_product.service.impl.Product_templateServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Account_move_purchase_order_rel;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order_line;
import cn.ibizlab.businesscentral.core.odoo_purchase.service.impl.Purchase_orderServiceImpl; import cn.ibizlab.businesscentral.core.odoo_purchase.service.impl.Purchase_orderServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order; import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
...@@ -16,6 +30,20 @@ import java.util.*; ...@@ -16,6 +30,20 @@ import java.util.*;
@Service("Purchase_orderExService") @Service("Purchase_orderExService")
public class Purchase_orderExService extends Purchase_orderServiceImpl { public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Autowired
Account_moveServiceImpl accountMoveService;
@Autowired
Product_productServiceImpl productService;
@Autowired
Product_templateServiceImpl productTemplateService;
@Autowired
Res_partnerServiceImpl partnerService;
@Override @Override
protected Class currentModelClass() { protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1); return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
...@@ -29,6 +57,21 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -29,6 +57,21 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order button_cancel(Purchase_order et) { public Purchase_order button_cancel(Purchase_order et) {
// 获取凭证录入的ID组
List<Account_move_purchase_order_rel> accountMovePurchaseOrderRels = accountMovePurchaseOrderRelService.selectByPurchaseOrderId(et.getId());
List<String> accountMoveIds = new ArrayList();
for(Account_move_purchase_order_rel accountMovePurchaseOrderRel : accountMovePurchaseOrderRels){
accountMoveIds.add(accountMovePurchaseOrderRel.getAccountMoveId().toString());
}
// 通过凭证录入的ID获取对应的凭证记录
List<Account_move> accountMoves = accountMoveService.getAccountMoveByIds(accountMoveIds);
for(Account_move accountMove : accountMoves){
if(StringUtils.compare(accountMove.getState(),"cancel")==0|| StringUtils.compare(accountMove.getState(),"draft")==0){
throw new RuntimeException("无法取消此采购订单。 您必须先取消相关的供应商账单。") ;
}
}
et.setState("cancel");
this.update(et);
return super.button_cancel(et); return super.button_cancel(et);
} }
/** /**
...@@ -39,6 +82,63 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -39,6 +82,63 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order button_confirm(Purchase_order et) { public Purchase_order button_confirm(Purchase_order et) {
// if(StringUtils.compare(et.getState(), "draft") == 0 || StringUtils.compare(et.getState(), "sent") == 0){
// // 链接_add_supplier_to_product()
// List<Purchase_order_line> lines = purchaseOrderLineService.selectByOrderId(et.getId());
// for(Purchase_order_line line : lines){
// // 联系人partner
// Res_partner partner = partnerService.get(et.getPartnerId());
//
// // 获取Product_product的供应商
// Product_product product = productService.getById(et.getProductId());
// if(line.getProductId() != null && ("") &&product.getSellerIds().length() <= 10){
// // 币种currency
// Res_currency toCurrency = new Res_currency();
// if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() != null){
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// }else if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() == null){
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// }else if(partner.getPropertyPurchaseCurrencyId() ==null && et.getCurrencyId() != null){
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// }
// // 价格price, 将价格转换成当前所用币种
// Double price = 0.0;
// if(et.getCurrencyId() == toCurrency.getId()){
// price = line.getPriceUnit();
// }else{
//// price = line.getPriceUnit() *
// }
//
// //
// Product_template productTemplate = productTemplateService.get(product.getProductTmplId());
// if(productTemplate.getUomPoId() != line.getProductUom()){
// Long default_uom = productTemplate.getUomPoId();
// // 计算price
// }
//
// // 创建供应商价格表记录
// Product_supplierinfo supplierinfo = new Product_supplierinfo();
// supplierinfo.setName(partner.getId());
// supplierinfo.setSequence();
// supplierinfo.setMinQty(0.0);
// supplierinfo.setPrice(price);
// supplierinfo.setCurrencyId(toCurrency.getId());
// supplierinfo.setDelay(0);
//
// // 按条件查找供应商
//
//
// }
// }
// log.warn("_add_supplier_to_product()");
//// if(StringUtils.compare(, "one_step") == 0 || ){
//// // button_approve()
//// log.warn("button_approve()");
//// }else{
//// et.setState("to approve");
//// }
// }
// this.update(et);
return super.button_confirm(et); return super.button_confirm(et);
} }
/** /**
...@@ -49,6 +149,9 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -49,6 +149,9 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order button_done(Purchase_order et) { public Purchase_order button_done(Purchase_order et) {
// 改变采购订单的状态为锁定
et.setState("done");
this.update(et);
return super.button_done(et); return super.button_done(et);
} }
/** /**
...@@ -59,6 +162,9 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -59,6 +162,9 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order button_unlock(Purchase_order et) { public Purchase_order button_unlock(Purchase_order et) {
// 改变采购订单的状态为解锁
et.setState("purchase");
this.update(et);
return super.button_unlock(et); return super.button_unlock(et);
} }
/** /**
...@@ -69,6 +175,14 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -69,6 +175,14 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order get_name(Purchase_order et) { public Purchase_order get_name(Purchase_order et) {
//
// String name = et.getName();
// if(et.getPartnerRef() != null){
// name += " (" + et.getPartnerRef() + ")";
// }
// if( && et.getAmountTotal() != null){
// name += ": " +
// }
return super.get_name(et); return super.get_name(et);
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册