Пример #1
0
    [Test] public void Indexer([Range(-1, 1)]        int val,
                               [Values(true, false)] bool arg)
    {
        var dec = new Dec();

        // init. with condition
        x = new Reckoning(arg, stack);
        x.context?.Traverse(dec);         // traverse a decorator
        var s0 = status.@unchecked(val);
        var s1 = x[s0];                   // exit the context

        o(dec.didReset, arg);             // did reset?
        o(s0, s1);                        // neutrality
    }
Пример #2
0
 [Test] public void Constructor([Values(true, false)] bool arg)
 {
     x = new Reckoning(arg, stack);
     o(x.context != null, arg);
 }
Пример #3
0
 [Test] public void Constructor_withCallInfo(
     [Values(true, false)] bool arg)
 {
     x = new Reckoning(arg, stack, ("path", "member", -1));
     o(x.context != null, arg);
 }
Пример #4
0
        /// <summary>
        /// 供应商对账
        /// </summary>
        /// <param name="checkType">往来单据付款类型</param>
        /// <param name="receiptInfo">往来单位收付款</param>
        /// <param name="description">描述备注</param>
        /// <param name="reckoningInfos">待添加的往来帐</param>
        /// <param name="stockOrderNos">入库单据集合</param>
        /// <param name="removeNos"></param>
        /// <param name="receiveBill">收款单</param>
        /// <param name="errorMsg">错误信息</param>
        /// <returns></returns>
        public static bool CheckCompany(int checkType, CompanyFundReceiptInfo receiptInfo,
                                        string description, IList <ReckoningInfo> reckoningInfos,
                                        IList <string> stockOrderNos, IList <string> removeNos, out CompanyFundReceiptInfo receiveBill, out string errorMsg)
        {
            receiveBill = null;
            var             codeManager        = new CodeManager();
            ICompanyCussent companyCussent     = new CompanyCussent(GlobalConfig.DB.FromType.Write);
            var             companyCussentInfo = companyCussent.GetCompanyCussent(receiptInfo.CompanyID); //判断往来单位是否为内部公司

            if (companyCussentInfo == null)
            {
                errorMsg = "往来单位信息获取失败";
                return(false);
            }
            var reckoningId   = Guid.NewGuid();
            var reckoningInfo = new ReckoningInfo(reckoningId, receiptInfo.FilialeId, receiptInfo.CompanyID, codeManager.GetCode(CodeType.PY), description,
                                                  receiptInfo.RealityBalance, (int)ReckoningType.Income,
                                                  (int)ReckoningStateType.Currently,
                                                  (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                  receiptInfo.ReceiptNo, Guid.Empty)
            {
                IsOut = receiptInfo.IsOut
            };
            IReckoning reckoning        = new Reckoning(GlobalConfig.DB.FromType.Write);
            var        thirdCompanyInfo = companyCussent.GetCompanyByRelevanceFilialeId(receiptInfo.FilialeId);

            #region 如果公司内部付款时 生成对应的已完成的收款往来单据)
            if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
            {
                if (thirdCompanyInfo == null)
                {
                    errorMsg = "付款公司未关联供应商";
                    return(false);
                }
                receiveBill = new CompanyFundReceiptInfo
                {
                    FilialeId            = companyCussentInfo.RelevanceFilialeId,
                    CompanyID            = thirdCompanyInfo.CompanyId,
                    PayBankAccountsId    = receiptInfo.ReceiveBankAccountId,
                    ReceiptType          = (int)CompanyFundReceiptType.Receive,
                    ReceiptStatus        = (int)CompanyFundReceiptState.Finish,
                    ReceiptID            = Guid.NewGuid(),
                    ReceiptNo            = codeManager.GetCode(CodeType.GT),
                    ApplyDateTime        = receiptInfo.ApplyDateTime,
                    PurchaseOrderNo      = "",
                    ReceiveBankAccountId = Guid.Empty,
                    StockOrderNos        = "",
                    DealFlowNo           = "",
                    FinishDate           = DateTime.Now,
                    AuditingDate         = receiptInfo.AuditingDate,
                    AuditorID            = receiptInfo.AuditorID,
                    Poundage             = 0,
                    ExecuteDateTime      = DateTime.Now,
                    Remark = string.Format("[公司内部付款单:{0}]", receiptInfo.ReceiptNo),
                    OtherDiscountCaption = "",
                    DiscountCaption      = "",
                    DiscountMoney        = 0,
                    DebarStockNos        = "",
                    LastRebate           = 0,
                    ApplicantID          = receiptInfo.ApplicantID,
                    AuditFailureReason   = "",
                    CompanyName          = thirdCompanyInfo.CompanyName,
                    ExpectBalance        = receiptInfo.RealityBalance,
                    HasInvoice           = receiptInfo.HasInvoice,
                    RealityBalance       = receiptInfo.RealityBalance,
                    IncludeStockNos      = "",
                    PaymentDate          = receiptInfo.PaymentDate,
                    SettleStartDate      = receiptInfo.SettleStartDate,
                    SettleEndDate        = receiptInfo.SettleEndDate
                };
            }
            #endregion
            switch (checkType)
            {
                #region //按采购单进行付款   如果往来单位是关联内部公司:ex:可得向可镜采购  那么可得付完款平账完成  可镜收款完成 平账
            case 1:
                var purchaseOrderNos = receiptInfo.PurchaseOrderNo.Split(',');
                if (purchaseOrderNos.Length > 1)
                {
                    IPurchasing purchasing = new Purchasing(GlobalConfig.DB.FromType.Read);
                    foreach (var purchaseOrderNo in purchaseOrderNos)
                    {
                        var totalPrice = purchasing.GetPurchasingAmount(purchaseOrderNo);
                        if (receiptInfo.DiscountMoney != 0)
                        {
                            totalPrice -= Math.Abs(receiptInfo.DiscountMoney);
                        }
                        if (receiptInfo.LastRebate != 0)
                        {
                            totalPrice -= Math.Abs(receiptInfo.LastRebate);
                        }
                        reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), receiptInfo.FilialeId, receiptInfo.CompanyID, codeManager.GetCode(CodeType.PY), description,
                                                             totalPrice, (int)ReckoningType.Income,
                                                             (int)ReckoningStateType.Currently,
                                                             (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                             purchaseOrderNo, Guid.Empty)
                        {
                            IsOut         = receiptInfo.IsOut,
                            LinkTradeType = (int)ReckoningLinkTradeType.PurchasingNo
                        });

                        if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                        {
                            reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, codeManager.GetCode(CodeType.PY), description,
                                                                 -totalPrice, (int)ReckoningType.Defray,
                                                                 (int)ReckoningStateType.Currently,
                                                                 (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                                 purchaseOrderNo, Guid.Empty)
                            {
                                IsOut         = receiptInfo.IsOut,
                                LinkTradeType = (int)ReckoningLinkTradeType.PurchasingNo
                            });
                        }
                    }
                    //将物流公司销售出库给销售公司的往来账平掉
                    reckoning.CheckByPurchaseOrder(purchaseOrderNos, reckoningInfo.FilialeId, receiptInfo.CompanyID, receiptInfo.SettleStartDate);
                    if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                    {
                        reckoning.CheckByPurchaseOrder(purchaseOrderNos, companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, receiptInfo.SettleStartDate);
                    }
                }
                else
                {
                    reckoningInfo.LinkTradeCode = receiptInfo.PurchaseOrderNo;
                    reckoningInfo.LinkTradeType = (int)ReckoningLinkTradeType.PurchasingNo;
                    reckoningInfos.Add(reckoningInfo);
                    //将物流公司销售出库给销售公司的往来账平掉
                    reckoning.CheckByPurchaseOrder(purchaseOrderNos, reckoningInfo.FilialeId, receiptInfo.CompanyID, receiptInfo.SettleStartDate);
                    if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                    {
                        reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, codeManager.GetCode(CodeType.PY), description,
                                                             -receiptInfo.RealityBalance, (int)ReckoningType.Defray,
                                                             (int)ReckoningStateType.Currently,
                                                             (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                             receiptInfo.PurchaseOrderNo, Guid.Empty)
                        {
                            IsOut         = receiptInfo.IsOut,
                            LinkTradeType = (int)ReckoningLinkTradeType.PurchasingNo
                        });
                        reckoning.CheckByPurchaseOrder(purchaseOrderNos, companyCussentInfo.RelevanceFilialeId, receiptInfo.CompanyID, receiptInfo.SettleStartDate);
                    }
                }

                break;
                #endregion

            case 2:      //按入库单进行付款
                var stockNos = receiptInfo.StockOrderNos.Split(',');
                reckoning.CheckByStorageTradeCode(stockNos, reckoningInfo.FilialeId, receiptInfo.CompanyID, receiptInfo.SettleStartDate);
                reckoningInfo.LinkTradeType = (int)ReckoningLinkTradeType.StockIn;
                reckoningInfos.Add(reckoningInfo);

                if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                {
                    reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, codeManager.GetCode(CodeType.PY), description,
                                                         -receiptInfo.RealityBalance, (int)ReckoningType.Defray,
                                                         (int)ReckoningStateType.Currently,
                                                         (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                         receiptInfo.ReceiptNo, Guid.Empty)
                    {
                        IsOut = receiptInfo.IsOut
                    });
                    reckoning.CheckByStorageTradeCode(stockNos, companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, receiptInfo.SettleStartDate);
                }
                break;

            case 3:     //按日期付款
                reckoningInfo.LinkTradeType = (int)ReckoningLinkTradeType.CompanyFundReceipt;
                var result = reckoning.CheckByDate(receiptInfo.CompanyID, reckoningInfo.FilialeId, receiptInfo.SettleStartDate, receiptInfo.SettleEndDate.AddDays(1).AddSeconds(-1), (int)CheckType.NotCheck, stockOrderNos, removeNos);
                if (result)
                {
                    if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                    {
                        reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, codeManager.GetCode(CodeType.PY), description,
                                                             -receiptInfo.RealityBalance, (int)ReckoningType.Defray,
                                                             (int)ReckoningStateType.Currently,
                                                             (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                             receiptInfo.ReceiptNo, Guid.Empty)
                        {
                            IsOut = receiptInfo.IsOut
                        });
                        //反向更新往来单位和公司的帐务
                        result = reckoning.CheckByDate(thirdCompanyInfo.CompanyId, companyCussentInfo.RelevanceFilialeId, receiptInfo.SettleStartDate, receiptInfo.SettleEndDate.AddDays(1).AddSeconds(-1), (int)CheckType.NotCheck, stockOrderNos, removeNos);
                        if (!result)
                        {
                            errorMsg = "反向更新往来单位和公司间往来帐状态失败!";
                            return(false);
                        }
                    }
                }
                else
                {
                    errorMsg = "按日期结算往来帐查询无效!";
                    return(false);
                }
                reckoningInfos.Add(reckoningInfo);
                break;

            default:
                if (companyCussentInfo.RelevanceFilialeId != Guid.Empty)
                {
                    reckoningInfos.Add(new ReckoningInfo(Guid.NewGuid(), companyCussentInfo.RelevanceFilialeId, thirdCompanyInfo.CompanyId, codeManager.GetCode(CodeType.PY), description,
                                                         -receiptInfo.RealityBalance, (int)ReckoningType.Defray,
                                                         (int)ReckoningStateType.Currently,
                                                         (int)CheckType.IsChecked, (int)AuditingState.Yes,
                                                         receiptInfo.ReceiptNo, Guid.Empty)
                    {
                        IsOut = receiptInfo.IsOut
                    });
                }
                reckoningInfo.LinkTradeType = (int)ReckoningLinkTradeType.CompanyFundReceipt;
                reckoningInfos.Add(reckoningInfo);
                break;
            }
            errorMsg = "";
            return(true);
        }