【问题标题】:How do you create a bank deposit using the Screen based API如何使用基于屏幕的 API 创建银行存款
【发布时间】:2016-10-05 05:34:48
【问题描述】:

我目前需要使用基于屏幕的 API 自动创建银行存款。

最好的方法是什么?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    这就是我设法做到的:

    class Payment
    {
        public string Module;
        public string Type;
        public string RefNbr;
        public decimal Amount;
    }
    class Program
    {
        static void Main(string[] args)
        {
            var paymentsToDeposit = new Payment[]
            {
                new Payment { Module = "AR", Type = "Payment", RefNbr = "000483", Amount = 100 },
                new Payment { Module = "AR", Type = "Payment", RefNbr = "000484", Amount = 200 },
            };
    
            Screen context = new Screen();
            context.CookieContainer = new System.Net.CookieContainer();
            context.Url = "http://localhost/bankDeposits/(W(53))/Soap/CA305000.asmx";
            context.Login("admin", "admin");
    
            Content bankDepositSchema = context.GetSchema();
    
            List<Command> commands = new List<Command>();
            commands.Add(new Value { Value = "<NEW>", LinkedCommand = bankDepositSchema.DepositSummary.ReferenceNbr });
            commands.Add(new Value { Value = "102000", LinkedCommand = bankDepositSchema.DepositSummary.CashAccount });
            commands.Add(new Value { Value = "test2", LinkedCommand = bankDepositSchema.DepositSummary.DocumentRef });
            commands.Add(new Value { Value = "OK", LinkedCommand = bankDepositSchema.AddPaymentToDeposit.ServiceCommands.DialogAnswer, Commit = true });
    
            decimal total = 0;
            foreach(Payment pmt in paymentsToDeposit)
            {
                commands.Add(new Key { Value = "='" + pmt.Module + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.DocModule.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.DocModule.ObjectName });
                commands.Add(new Key { Value = "='" + pmt.Type + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.Type.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.Type.ObjectName });
                commands.Add(new Key { Value = "='" + pmt.RefNbr + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.ReferenceNbr.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.ReferenceNbr.ObjectName });
                commands.Add(new Value { Value = "True", LinkedCommand = bankDepositSchema.AddPaymentToDeposit.Selected, Commit = true });
                total += pmt.Amount;
            }
    
            commands.Add(bankDepositSchema.Actions.AddPayment);
            commands.Add(new Value { Value = total.ToString(System.Globalization.CultureInfo.InvariantCulture), LinkedCommand = bankDepositSchema.DepositSummary.ControlTotal });
            commands.Add(bankDepositSchema.Actions.Save);
    
            context.Submit(commands.ToArray());
            context.Logout();
        }
    }
    

    【讨论】:

    • 嗨@samol518,非常感谢你添加这个,它在类似的事情上帮助了我很多。但是,我是 hitting my head 在流程表单上“选择”多个项目 - 您是否有任何技巧可以解决这个问题?再次感谢您在 Acumatica 社区所做的一切!
    猜你喜欢
    • 1970-01-01
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    相关资源
    最近更新 更多