Exemplo n.º 1
0
        static public InitAccountPayable getInctance()
        {
            if (m_instance == null)
            {
                m_instance = new InitAccountPayable();
            }

            return(m_instance);
        }
Exemplo n.º 2
0
        private double getNewBalance(CashAccountReceivableDetailTable record)
        {
            double newBalance = 0;
            double oldBalance = 0;

            /*
             * 函数逻辑
             * 本次交易后欠款余额的最终结果取决于本次交易单据的类型
             * 如果本张单据是期初数据,交易后欠款等于本次交易额
             * 如果本张单据是付款单,交易后欠款月等于之前的欠款额减去本次交易额
             * 如果本张单据是销售出库,交易后欠款余额等于之前的余额加上本次交易额
             * */

            if (record.billTypeName.IndexOf("期初数据") != -1)
            {
                newBalance = record.balance;
            }
            else
            {
                InitAccountReceivableTable temp = InitAccountPayable.getInctance().getInfoFromCustomerOrSupplierID(record.customerOrSupplierID);

                if (temp != null)
                {
                    oldBalance = temp.balance;
                }

                if (record.billTypeName.IndexOf("付款") != -1 ||
                    record.billTypeName == "采购退货")
                {
                    newBalance = oldBalance - record.turnover;
                }
                else
                {
                    newBalance = oldBalance + record.turnover;
                }

                InitAccountReceivableTable newRecord = new InitAccountReceivableTable();
                newRecord.balance              = newBalance;
                newRecord.tradingDate          = record.tradingDate;
                newRecord.customerOrSupplierID = record.customerOrSupplierID;

                InitAccountPayable.getInctance().update(temp.pkey, newRecord, false);
            }

            return(newBalance);
        }
Exemplo n.º 3
0
        private void updateAccountPayableData(string billNumber)
        {
            PurchaseInOrderTable accountPayableData = getPurchaseInfoFromBillNumber(billNumber);

            if (accountPayableData.purchaseType == "赊购")
            {
                InitAccountReceivableTable record = new InitAccountReceivableTable();

                // 应付款金额
                double turnover = Convert.ToDouble(accountPayableData.sumMoney.ToString());

                string message = "单据 [" + accountPayableData.billNumber + "] 采购类型为赊购,";
                message += "系统会自动产生一笔应付账款信息记录到供应商 [" + accountPayableData.supplierName + "] 账户下,";
                message += "请确实应付账款金额,然后点击【确定】按钮(如需调整金额,请点击调整【金额调整】按钮,再点击【确定】)";

                FormAdjustAmount faa = new FormAdjustAmount("应付账款金额确认", message, accountPayableData.totalMoney);
                faa.ShowDialog();
                turnover = faa.getAmount();

                if (!m_isRedBill)
                {
                    if (!InitAccountPayable.getInctance().checkcustomerOrSupplierIDIsExist(accountPayableData.supplierId))
                    {
                        /* 说明
                         * 系统应收应付账款的汇总表和详细的收款还款记录是分开存放,并且默认情况下会相互更新
                         * 比如正常的逻辑(用于应付应付胀库初始化模块):
                         *      当在应付账款汇总表插入一条记录的时候,程序会自动插入一条期初数据到应付账款详细表
                         *      当有一笔交易更新了应付账款表时,程序会自动查询应付账款统计表,更新对应供应商的欠款余额
                         * 此处的逻辑如下:
                         *      当发生采购入库赊购业务时候,自动产生一条应付账款信息
                         *      这里需要首先查询下系统中是否存在跟该供应商的应付账款
                         *          如果不存在,需要同时更新应付账款汇总表和应付账款详细表,并且不需要两个表之间相同更新余额
                         *          如果存在,只需要更新应付账款详细表,应付账款详细表会自动更新应付账款汇总表中的余额
                         */

                        // 把数据插入到应付账款汇总表
                        InitAccountReceivableTable accountReceivableCount = new InitAccountReceivableTable();
                        accountReceivableCount.customerOrSupplierID = accountPayableData.supplierId;                // 供应商ID
                        accountReceivableCount.tradingDate          = accountPayableData.paymentDate;               // 交易日期
                        accountReceivableCount.balance = turnover;
                        InitAccountPayable.getInctance().insert(accountReceivableCount, false, false);

                        // 把数据插入到应付账款明细表
                        CashAccountReceivableDetailTable cashAccountReceivableDetailrecord = new CashAccountReceivableDetailTable();
                        cashAccountReceivableDetailrecord.customerOrSupplierID = accountPayableData.supplierId;  // 供应商ID
                        cashAccountReceivableDetailrecord.billTypeName         = "采购入库";                         // 账单类型
                        cashAccountReceivableDetailrecord.billNumber           = billNumber;                     // 单据号
                        cashAccountReceivableDetailrecord.tradingDate          = accountPayableData.paymentDate; // 交易日期
                        cashAccountReceivableDetailrecord.turnover             = turnover;                       // 应付款金额
                        cashAccountReceivableDetailrecord.staffID = accountPayableData.businessPeopleId;         // 采购员ID
                        CashAccountPayableDetail.getInctance().insert(cashAccountReceivableDetailrecord, false);
                    }
                    else
                    {
                        // 把数据插入到应付账款明细表
                        CashAccountReceivableDetailTable cashAccountReceivableDetailrecord = new CashAccountReceivableDetailTable();
                        cashAccountReceivableDetailrecord.customerOrSupplierID = accountPayableData.supplierId;  // 供应商ID
                        cashAccountReceivableDetailrecord.billTypeName         = "采购入库";                         // 账单类型
                        cashAccountReceivableDetailrecord.billNumber           = billNumber;                     // 单据号
                        cashAccountReceivableDetailrecord.tradingDate          = accountPayableData.paymentDate; // 交易日期
                        cashAccountReceivableDetailrecord.turnover             = turnover;                       // 应付款金额
                        cashAccountReceivableDetailrecord.staffID = accountPayableData.businessPeopleId;         // 采购员ID
                        CashAccountPayableDetail.getInctance().insert(cashAccountReceivableDetailrecord, true);
                    }
                }
                else
                {
                    // 代表是红字凭证 把数据插入到应付账款明细表
                    CashAccountReceivableDetailTable cashAccountReceivableDetailrecord = new CashAccountReceivableDetailTable();
                    cashAccountReceivableDetailrecord.customerOrSupplierID = accountPayableData.supplierId;  // 供应商ID
                    cashAccountReceivableDetailrecord.billTypeName         = "采购退货";                         // 账单类型
                    cashAccountReceivableDetailrecord.billNumber           = billNumber;                     // 单据号
                    cashAccountReceivableDetailrecord.tradingDate          = accountPayableData.paymentDate; // 交易日期
                    cashAccountReceivableDetailrecord.turnover             = turnover;                       // 应付款金额
                    cashAccountReceivableDetailrecord.staffID = accountPayableData.businessPeopleId;         // 采购员ID
                    CashAccountPayableDetail.getInctance().insert(cashAccountReceivableDetailrecord, true);
                }
            }
        }