K3 Wise 15.0以前版本无法实现出库单审核后自动生成销售专用发票的解决方案
近期有客户提出希望销售出库单审核以后能够自动生成销售专用发票的需求,目前K3WISE15.1版本支持该功能,15.0以前的版本,包括15.0版本都不支持该功能。
15.1版本解决方案
操作路径:系统设置—系统设置—销售管理—系统设置
打开系统参数设置后找到销售系统选项中将“销售出库单审核后自动生成销售发票”设置上参数值。
15.0包括15.0以前的版可以通过触发器实现该功能的思路如下:
(只给出了思路,仅供参考,代码中包括有自定义字段不能直接复制使用,需要根据具体业务调整修改)
create trigger 触发器名
ON [dbo].[ICStockBill]
OR UPDATE AS
DECLARE
@Status INT,
@TranType INT,
@InterID INT,
@SaleInterID INT,
@InvoiceID INT,
@BillNo VARCHAR(20),
@SaleBillNo VARCHAR(20),
@DigitWidth INT,
@Amount DECIMAL(15, 5),
@ID INT,
@GroupNo INT,
@BillerID INT;
SELECT @BillerID = FUserID FROM t_User WHERE FName = 'Administrator';
SELECT
@BillNo = FBillNo,
@Status = FStatus,
@TranType = FTranType,
@InterID = FInterID,
@BillerID = FBillerID,
@InvoiceID = FRelateInvoiceID
FROM inserted;
IF UPDATE(FCheckerID) AND @Status = 1 AND @TranType = 21 AND @InvoiceID = 0
BEGIN
EXEC GetICMaxNum 'ICSALE',@SaleInterID OUTPUT,1,0
exec p_BM_GetBillNo 80,@SaleBillNo OUTPUT
INSERT INTO ICSaleEntry
(FInterID,FEntryID,FItemID,FQty,FPrice,FAmount,FTaxRate,FTaxAmount,FUnitID,FAuxPrice,FAuxQty,FTaxPrice,FAuxTaxPrice,FSourceEntryID,FStdAmount,FStdTaxAmount,FAmountincludetax,FStdAmountincludetax,FBatchNo,FClassID_SRC,FKFDate,FKFperiod,FPeriodDate,FPriceDiscount,FAuxPriceDiscount,FSourceTranType,FSourceInterId,FSourceBillNo,FRemainQty,FRemainAmount,FRemainAmountFor,FNote,FMTONo,FEntrySelfI0471,FEntrySelfI0472,FEntrySelfI0473,FEntrySelfI0474,FEntrySelfI0475,FEntrySelfI0476,FEntrySelfI0477,FEntrySelfI0478,FEntrySelfI0479)
INSERT INTO ICSale (FInterID,FBillNo,FTranType,FROB,FClassTypeID,FYear,FPeriod,FFincDate,FDate,FCustID,FDeptID,FEmpID,FBillerID,FCurrencyID,FExchangeRate,FCompactNo,FSaleStyle,FAcctID,FYearPeriod,FYtdIntRate,FNote,FSelTranType,FManagerID,FBrID,FVchInterID,FSettleID,FSysStatus,FCussentAcctID,FSettleDate,FItemClassID,FAdjustExchangeRate,FHeadSelfI0459)
SELECT @ID = ISNULL(MAX(FID), 0) + 1 FROM t_RP_Contact;
SELECT @Amount = SUM(FConsignAmount) FROM ICStockBillEntry WHERE FInterID = @InterID;
INSERT INTO t_RP_Contact (FID,FYear,FPeriod,FRP,FType,FDate,FFincDate,FNumber,FCustomer,FDepartment,FEmployee,FCurrencyID,FExchangeRate,FAmount,FAmountFor,FRemainAmount,FRemainAmountFor,FInvoiceID,FRPDate,FK3Import,FBillType,FInvoiceType,FItemClassID,FExplanation,FPreparer,FStatus,FToBal)
INSERT INTO 表名(FOrgID,FDate,FAmount,FAmountFor,FRemainAmount,FRemainAmountFor,FRP,FInterID)
UPDATE t_RP_Plan_Ar
SET FLastTradeDate = FDate,FLastTradeAmount = @Amount
FROM t_Organization, inserted
WHERE FItemID = FSupplyID;
SELECT @GroupNo = ISNULL(MAX(FGroupNo), 0) + 1 FROM ICHookRelations;
INSERT INTO ICHookR
SELECT GroupNo,1,0,0,SaleInterID,SaleBillNo,'X',MONTH(FDate),YEAR(FDate),0,FDate,FEntryID,FItemID,0,FQty,FSupplyID,0,@BillerID,0,FSaleStyle,
FConsignAmount,80,0
FROM ICStockBillEntry
LEFT JOIN ICStockBill ON ICStockBill.FInterID = ICStockBillEntry.FInterID
WHERE ICStockBillEntry.FInterID = @InterID
UNION
SELECTGroupNo,1,0,1,@InterID,@BillNo,'X',MONTH(FDate),YEAR(FDate),0,FDate,FEntryID,FItemID,0,FQty,FSupplyID,0,@BillerID,0,FSaleStyle,FConsignAmount,21,0 FROM ICStockBillEntry
LEFT JOIN ICStockBill ON ICStockBill.FInterID = ICStockBillEntry.FInterID
WHERE ICStockBillEntry.FInterID = @InterID;
UPDATE ICStockBill
SET FRelateInvoiceID = @SaleInterID,FHookInterID = @GroupNo,FChildren=1,FHookStatus = 2
WHERE FInterID = @InterID;
UPDATE ICStockBillEntry
SET FAllHookQTY = FQty,FCurrentHookQTY = FQty,FQtyInvoice = FQty,FAuxQtyInvoice = FQty
WHERE FInterID = @InterID;
UPDATE ICSale
SET FCheckDate = FDate,FCheckerID = @BillerID,FStatus = 1,FHookerID = @BillerID,FArApStatus = FArApStatus | 1,FHookStatus = 2, FHookInterID = @GroupNo
WHERE FInterID = @SaleInterID;
UPDATE ICSaleEntry
SET FAllHookQTY = FQty,FAllHookAmount = FAmountincludetax,FCurrentHookQTY = FQty,FCurrentHookAmount = FAmountincludetax,
FStdAllHookAmount = FAmountincludetax,FStdCurrentHookAmount = FAmountincludetax
WHERE FInterID = @SaleInterID
END
这个之前都是花钱实现的
K3 Wise 15.0以前版本无法实现出库单审核后自动生成销售专用发票的解决方案
本文2024-09-16 15:50:44发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-5433.html