【二开插件】销售普通发票自动开具金税发票

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

【二开插件】销售普通发票自动开具金税发票

需求:销售普通发票审核后,自动开具金税发票,不需要点击“金税发票开具”按钮


public class CreateIV : AbstractOperationServicePlugIn
{
            public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
            {
                base.AfterExecuteOperationTransaction(e);
                OperateResultCollection oResult = this.OperationResult.OperateResult;
                if (this.OperationResult.IsSuccess && oResult.Count > 0)
                {
                    foreach (DynamicObject o in e.DataEntitys)
                    {
                            PushIV(o);
                    }
                }
            }
            
            private void PushIV(DynamicObject obj)
            {
                string invoiceid = obj["F_invoice_id"].ToString();
                #region 下推金税
                OperateResultCollection operateResults = new OperateResultCollection();
                Dictionary<string, string> sourceBills = new Dictionary<string, string>();
                sourceBills.Add(obj["Id"].ToString(), obj["BillNo"].ToString());
                GoldenTaxServiceHelper.PushGTInvoice(this.Context, "IV_SALESOC", "IV_GTINVOICE", sourceBills, operateResults, true, "0");
                //GTCommonFunction.ShowOperateResult(this.View, operateResults);
                #endregion
    
               //下推失败记录信息到操作日志
                var logs = new List<LogObject>();
                foreach(OperateResult op in operateResults)
                {
                    if (!op.SuccessStatus)
                    {
                        LogObject log = new LogObject
                        {
                            pkValue = "0",
                            Description = op.Message,
                            OperateName = "自动开具金税发票",
                            ObjectTypeId = "BOS_SCHEDULETYPE",
                            SubSystemId = "BOS",
                            Environment = OperatingEnvironment.BizOperate
                        };
                        logs.Add(log);
                    }
                }
                if (logs.Count > 0)
                {
                    LogServiceHelper.BatchWriteLog(this.Context, logs);
                }
          }
}


注:

1.具体可反编译销售发票单据的表单插件Kingdee.K3.FIN.IV.Business.PlugIn.GoldenTax.GTOperateEdit中的BarItemClick方法自行查看,最终是调用GoldenTaxServiceHelper.PushGTInvoice方法真正进行开票。

2.以上代码不涉及超额拆分开票的情况


相关链接:金税开票单设置邮件和短信字段,支持开具电子发票支持自动发送邮件和短信功能    

【二开插件】销售普通发票自动开具金税发票

需求:销售普通发票审核后,自动开具金税发票,不需要点击“金税发票开具”按钮public class CreateIV : AbstractOperationServicePlugIn{ ...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息