生成发票的关键sql语句
SELECT v1.FInterID,u1.FEntryID,v1.FHookStatus FROM ICStockBill v1 INNER JOIN ICStockBillEntry u1 ON v1.FInterID=u1.FInterID WHERE 1=1 and v1.FStatus>0 AND v1.FHookStatus<>2 And (u1.FQty-u1.FQtyInvoice)*sign(v1.FRob)>0 and v1.FInterID=178151 AND u1.FEntryID=1 AND v1.FTranType=21
根据具体情况,看不能生成发票的原因,FStatus>0、FHookStatus<>2 、(u1.FQty-u1.FQtyInvoice)*sign(v1.FRob)>0
看是否关联发票或单据
select FHookStatus,FRelateInvoiceID,FHookInterID,FBillNo from ICStockBill where FBillNo in ('XOUT006665','XOUT006240','XOUT006239')
FHookStatus 勾稽状态
FHookInterID 勾稽的单据ID
FRelateInvoiceID 勾稽的关联发票号
如果FHookInterID、FRelateInvoiceID是0 可以直接update勾稽状态