package com.xunhong.erp.turbo.biz.app.executor.cmd;

import com.xunhong.erp.turbo.api.biz.dto.cmd.PurchaseOrderFinalApproveCmd;
import com.xunhong.erp.turbo.biz.domain.gateway.ExpenseRecordGateway;
import com.xunhong.erp.turbo.biz.domain.gateway.PurchaseOrderGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author shenyifei
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class PurchaseOrderFinalApproveCmdExe {

	private final PurchaseOrderGateway purchaseOrderGateway;

	private final ExpenseRecordGateway expenseRecordGateway;

	@Transactional
	public void execute(PurchaseOrderFinalApproveCmd purchaseOrderFinalApproveCmd) {
		purchaseOrderGateway.finalApprove(purchaseOrderFinalApproveCmd);

		// 计提费计入发货日期的花销
		expenseRecordGateway.addProvision(purchaseOrderFinalApproveCmd.getOrderId());
	}
}
