| @ -0,0 +1,120 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using BWP.B3ButcherManage.BO; | |||
| using BWP.B3ButcherManageExport.BL; | |||
| using BWP.B3ExportBase; | |||
| using BWP.B3ExportBase.Utils; | |||
| using BWP.B3Frameworks; | |||
| using BWP.Web.Pages.B3ExportBase; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using Forks.EnterpriseServices.DomainObjects2.DQuery; | |||
| using TSingSoft.WebControls2; | |||
| namespace BWP.Web.Pages.B3ButcherManageExport.NC_.PayToNc_ | |||
| { | |||
| public class PayToNcList : ExportBaseList<Pay, IPayToNcBL> | |||
| { | |||
| protected override string DoExport(List<long> idList) | |||
| { | |||
| if (idList.Count == 0) | |||
| { | |||
| throw new ApplicationException("请选择单据!"); | |||
| } | |||
| if (_dfcUrl.IsEmpty) | |||
| { | |||
| throw new ApplicationException("请选择外部系统!"); | |||
| } | |||
| BL.Export(idList, long.Parse(_dfcUrl.Value), _billDate.Value); | |||
| return BIFactory.GetLastMessage(); | |||
| } | |||
| private ChoiceBox _dfcUrl; | |||
| private DFDateInput _billDate; | |||
| protected override void AddExportControl(HLayoutPanel hbox) | |||
| { | |||
| hbox.Add(new SimpleLabel("外部系统")); | |||
| _dfcUrl = hbox.Add(new ChoiceBox()); | |||
| _dfcUrl.DataKind = B3ExportBaseConsts.DataSources.外部系统; | |||
| _dfcUrl.EnableInputArgument = true; | |||
| _dfcUrl.SmartOrderEnabled = false; | |||
| _dfcUrl.EnableTopItem = true; | |||
| _dfcUrl.Width = 130; | |||
| hbox.Add(new SimpleLabel("日期")); | |||
| _billDate = hbox.Add(new DFDateInput()); | |||
| _billDate.Value = DateTime.Today; | |||
| base.AddExportControl(hbox); | |||
| } | |||
| protected override void AddQueryControls(VLayoutPanel vPanel) | |||
| { | |||
| vPanel.Add(CreateDefaultBillQueryControls((panel, config) => | |||
| { | |||
| config.Add("BillState"); | |||
| config.Add("Account_ID"); | |||
| config.Add("Supplier_ID"); | |||
| config.Add("Employee_ID"); | |||
| config.Add("Department_ID"); | |||
| config.Add("AccountingUnit_ID"); | |||
| config.Add("Date"); | |||
| })); | |||
| } | |||
| protected override void AddDFBrowseGridColumn(DFBrowseGrid grid, string field) | |||
| { | |||
| base.AddDFBrowseGridColumn(grid, field); | |||
| if (field == "ID") | |||
| { | |||
| AddDFBrowseGridColumn(grid, "AccountingUnit_Name"); | |||
| } | |||
| if (field == "BillState") | |||
| { | |||
| AddDFBrowseGridColumn(grid, "Date"); | |||
| AddDFBrowseGridColumn(grid, "Supplier_Name"); | |||
| AddDFBrowseGridColumn(grid, "Account_Name"); | |||
| AddDFBrowseGridColumn(grid, "Money"); | |||
| } | |||
| } | |||
| protected override DQueryDom GetQueryDom() | |||
| { | |||
| var dom = base.GetQueryDom(); | |||
| dom.EAddCheckedCondition(dom.From.RootSource.Alias); | |||
| return dom; | |||
| } | |||
| protected override void OnLoad(EventArgs e) | |||
| { | |||
| base.OnLoad(e); | |||
| if (!IsPostBack) | |||
| { | |||
| var tuple = ExportConfigUtil.LoadDefaultExtSystems(MethodID); | |||
| if (tuple != null) | |||
| { | |||
| _dfcUrl.Value = tuple.Item1.ToString(); | |||
| _dfcUrl.DisplayValue = tuple.Item2; | |||
| } | |||
| } | |||
| } | |||
| public override string Url | |||
| { | |||
| get { return "~/B3ButcherManageExport/NC_/PayToNc_/PayToNcList.aspx"; } | |||
| } | |||
| protected override string EditUrl | |||
| { | |||
| get | |||
| { | |||
| return "B3ButcherManage/Bills/Pay_/PayEdit.aspx"; | |||
| } | |||
| } | |||
| protected override string Caption | |||
| { | |||
| get { return "付款单导NC凭证"; } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,76 @@ | |||
| <?xml version="1.0" encoding="utf-8" ?> | |||
| <Select xmlns="urn:XDQuery"> | |||
| <Columns> | |||
| <Field name="ID"/> | |||
| </Columns> | |||
| <From> | |||
| <DmoClass class="BWP.B3ButcherManage.BO.Pay, B3ButcherManage"/> | |||
| </From> | |||
| <Where> | |||
| <And> | |||
| <EQ> | |||
| <Field name="ID"/> | |||
| <QBE paramName="ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="Supplier_ID"/> | |||
| <QBE paramName="Supplier_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="Account_ID"/> | |||
| <QBE paramName="Account_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="AccountingUnit_ID"/> | |||
| <QBE paramName="AccountingUnit_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="Department_ID"/> | |||
| <QBE paramName="Department_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="Employee_ID"/> | |||
| <QBE paramName="Employee_ID"/> | |||
| </EQ> | |||
| <EQ> | |||
| <Field name="IsLocked"/> | |||
| <QBE paramName="IsLocked"/> | |||
| </EQ> | |||
| <Contains> | |||
| <Field name="Remark"/> | |||
| <QBE paramName="Remark"/> | |||
| </Contains> | |||
| <Contains> | |||
| <Field name="CreateUser_Name"/> | |||
| <QBE paramName="CreateUser_Name"/> | |||
| </Contains> | |||
| <Contains> | |||
| <Field name="CheckUser_Name"/> | |||
| <QBE paramName="CheckUser_Name"/> | |||
| </Contains> | |||
| <GreaterThanOrEqual> | |||
| <Field name="CreateTime"/> | |||
| <QBE paramName="MinCreateTime" /> | |||
| </GreaterThanOrEqual> | |||
| <LessThanOrEqual> | |||
| <Field name="CreateTime"/> | |||
| <QBE paramName="MaxCreateTime"/> | |||
| </LessThanOrEqual> | |||
| <GreaterThanOrEqual> | |||
| <Field name="Date"/> | |||
| <QBE paramName="MinDate" /> | |||
| </GreaterThanOrEqual> | |||
| <LessThanOrEqual> | |||
| <Field name="Date"/> | |||
| <QBE paramName="MaxDate"/> | |||
| </LessThanOrEqual> | |||
| <EQ> | |||
| <Field name="BillState"/> | |||
| <QBE paramName ="BillState"/> | |||
| </EQ> | |||
| </And> | |||
| </Where> | |||
| </Select> | |||
| @ -0,0 +1,88 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using BWP.B3ButcherManage.BO; | |||
| using BWP.B3ExportBase; | |||
| using BWP.B3ExportBase.BL; | |||
| using BWP.B3ExportBase.BO; | |||
| using BWP.B3Frameworks; | |||
| using Forks.EnterpriseServices; | |||
| using Forks.EnterpriseServices.BusinessInterfaces; | |||
| using TSingSoft.WebPluginFramework; | |||
| using TSingSoft.WebPluginFramework.BIPlugins.BLEvents; | |||
| namespace BWP.B3ButcherManageExport.BL | |||
| { | |||
| [BusinessInterface(typeof(PayToNcBL))] | |||
| public interface IPayToNcBL : INcBL<Pay> | |||
| { | |||
| void Export(List<long> idList, long p, DateTime? nullable); | |||
| } | |||
| [LogicName("付款单导NC凭证")] | |||
| [BindToFeature("B3ButcherManageExport.0001")] | |||
| [ExportID(B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport, B3ButcherManageExportConsts.ExportIDOffsets.PayToNc)] | |||
| public class PayToNcBL : NcBL<Pay>, IPayToNcBL | |||
| { | |||
| protected override NcUfinterface CreateUfinterface(IList<Pay> dmos) | |||
| { | |||
| var scriptHelper = new PythonScriptHelper(string.Empty, Config.Script, this); | |||
| scriptHelper.AddLocalVar("dmos", dmos); | |||
| if (Version == "6.3") | |||
| { | |||
| { | |||
| var bills = BO.NcVouchers.New(); | |||
| scriptHelper.AddLocalVar("vouchers", bills); | |||
| scriptHelper.Execute(); | |||
| var i = 0; | |||
| foreach (var bill in bills.Bills) | |||
| { | |||
| BillIDs.Add(i, bill.B2BillIDs); | |||
| i++; | |||
| } | |||
| return bills; | |||
| } | |||
| } | |||
| throw new Exception("未实现导出方法"); | |||
| } | |||
| public override short GetMethodID() | |||
| { | |||
| return B3FrameworksConsts.DmoTypeIDBases.B3ButcherManageExport + B3ButcherManageExportConsts.ExportIDOffsets.PayToNc; | |||
| } | |||
| public DateTime Date { get; set; } | |||
| public void Export(List<long> dmoIDs, long extSystemID, DateTime? date) | |||
| { | |||
| Date = date ?? BLContext.Today; | |||
| Export(dmoIDs, extSystemID); | |||
| } | |||
| public void CheckAccountingUnit(IEnumerable<AdvancePay> dmos) | |||
| { | |||
| var groups = dmos.GroupBy(x => x.AccountingUnit_Name); | |||
| var count = groups.Count(); | |||
| if (count > 1) | |||
| { | |||
| throw new ApplicationException("一次导出只能选择同一个会计单位下的单据"); | |||
| } | |||
| } | |||
| public string GetSumNumber(IEnumerable<Pay_Detail> details) | |||
| { | |||
| return details.Sum(x => (x.WeighBill_BuyNum ?? 0)).ToString(); | |||
| } | |||
| public string GetSumWeight(IEnumerable<Pay_Detail> details) | |||
| { | |||
| return details.Sum(x => (x.WeighBill_BuyWeigh1 ?? 0).Value).ToString("0.00"); | |||
| } | |||
| public string GetStatPayDate(Pay dmo, string format) | |||
| { | |||
| if (dmo.Details.Count == 0) | |||
| return string.Empty; | |||
| return GetDateTime(dmo.Details[0].StatPay_Date, format); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,143 @@ | |||
| from TSingSoft.Butchery_ZiYuan.BO import NcVoucher; | |||
| from TSingSoft.Butchery_ZiYuan.BO import NcVoucherEntry; | |||
| from TSingSoft.Butchery_ZiYuan.BO import Items; | |||
| from TSingSoft.Butchery_ZiYuan.BO import Otheruserdata; | |||
| from System import Convert; | |||
| class BLMethodEvents(BLMethodEventsBase): | |||
| def before(self): | |||
| self.proxy.MinDmoProperties.Add("Date"); | |||
| self.proxy.MinDmoProperties.Add("Supplier_Name"); | |||
| self.proxy.MinDmoProperties.Add("Money"); | |||
| self.proxy.MinDmoProperties.Add("AccountingUnit_ID"); | |||
| self.proxy.MinDmoProperties.Add("AccountingUnit_Name"); | |||
| self.proxy.MinDmoProperties.Add("Employee_Name"); | |||
| self.proxy.MinDetailProperties.Add("ID"); | |||
| self.proxy.MinDetailProperties.Add("Pay_ID"); | |||
| self.proxy.MinDetailProperties.Add("StatPay_Date"); | |||
| self.proxy.MinDetailProperties.Add("WeighBill_BuyNum"); | |||
| self.proxy.MinDetailProperties.Add("WeighBill_BuyWeigh1"); | |||
| self.proxy.MinDetailProperties.Add("Money"); | |||
| self.proxy.MinDetailProperties.Add("CheckTareWeightPrice"); | |||
| self.proxy.MinPreDetailProperties.Add("ID"); | |||
| self.proxy.MinPreDetailProperties.Add("Pay_ID"); | |||
| self.proxy.MinPreDetailProperties.Add("AdvancePay_Money"); | |||
| def execute(self): | |||
| self.proxy.CheckAccountingUnit(dmos); | |||
| voucher = NcVoucher(); | |||
| for dmo in dmos: | |||
| self.emptyError(dmo.Date,"付款日期不能为空"); | |||
| self.emptyError(dmo.Supplier_Name,"供应商不能为空"); | |||
| #self.emptyError(dmo.Employee_Name,"经办人不能为空"); | |||
| voucher.B2BillIDs.Add(dmo.ID); | |||
| voucher.Head.Company = dmo.AccountingUnit_Name; | |||
| if dmo.AccountingUnit_ID==5: | |||
| voucher.Head.VoucherType = "QHC凭证"; | |||
| else: | |||
| voucher.Head.VoucherType = "记账凭证"; | |||
| voucher.Head.FiscalYear = self.proxy.GetDateTime(gToday,"yyyy"); | |||
| voucher.Head.AccountingPeriod = self.proxy.GetDateTime(gToday,"MM"); | |||
| voucher.Head.Date = self.proxy.GetDateTime(gToday,"yyyy-MM-dd"); | |||
| voucher.Head.Signature = "Y"; | |||
| voucher.Head.VoucherMakingSystem = "总账"; | |||
| voucher.Head.Reserve2 = "N"; | |||
| voucher.Head.Enter = gUser.Name; | |||
| voucher.Head.VoucherId = "0"; | |||
| voucher.Head.AttachmentNumber = "0"; | |||
| vouchers.Bills.Add(voucher); | |||
| entryid = 0; | |||
| for dmo in dmos: | |||
| if dmo.AccountingUnit_ID == 1: | |||
| entryid = entryid + 1; | |||
| entry = NcVoucherEntry(); | |||
| voucher.Body.Entrys.Add(entry); | |||
| entry.EntryId = str(entryid); | |||
| entry.AccountCode = "集团外应付生猪款" ; | |||
| entry.Abstract =self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd") +"支付" +self.proxy.GetStatPayDate(dmo,"yyyy-MM-dd")+dmo.Supplier_Name + self.proxy.GetSumNumber(dmo.Details)+ "头"+self.proxy.GetSumWeight(dmo.Details)+"KG生猪尾款"; | |||
| entry.Currency = "CNY"; | |||
| entry.ExchangeRate2 = "1" ; | |||
| entry.PrimaryDebitAmount = str(dmo.Money) ; | |||
| entry.NaturalDebitCurrency = str(dmo.Money) ; | |||
| item =Items(); | |||
| item.Name = "供应商辅助核算"; | |||
| item.Value = dmo.Supplier_Name; | |||
| entry.Accountings.Items.Add(item); | |||
| otherUserDate = Otheruserdata(); | |||
| entry.Otheruserdata = otherUserDate; | |||
| entry.Otheruserdata.Cashflowcase.Money = str(dmo.Money) ; | |||
| entry.Otheruserdata.Cashflowcase.Moneymain = str(dmo.Money) ; | |||
| entry.Otheruserdata.Cashflowcase.PkCashflow = "购买商品、接受劳务支付的现金"; | |||
| for dmo in dmos: | |||
| if dmo.AccountingUnit_ID == 1: | |||
| entryid = entryid + 1; | |||
| entry = NcVoucherEntry(); | |||
| voucher.Body.Entrys.Add(entry); | |||
| entry.EntryId = str(entryid); | |||
| entry.AccountCode = "银行存款_收购" ; | |||
| entry.Abstract =self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd") +"支付" +self.proxy.GetStatPayDate(dmo,"yyyy-MM-dd")+dmo.Supplier_Name + self.proxy.GetSumNumber(dmo.Details)+ "头"+self.proxy.GetSumWeight(dmo.Details)+"KG生猪尾款"; | |||
| entry.Settlement = "电汇"; | |||
| entry.Currency = "CNY"; | |||
| entry.ExchangeRate2 = "1" ; | |||
| entry.DocumentDate = self.proxy.GetDateTime(gToday,"yyyy-MM-dd"); | |||
| entry.PrimaryCreditAmount = str(dmo.Money) ; | |||
| entry.NaturalCreditCurrency = str(dmo.Money) ; | |||
| voucher2 = NcVoucher(); | |||
| for dmo in dmos: | |||
| voucher2.B2BillIDs.Add(dmo.ID); | |||
| voucher2.Head.Company = dmo.AccountingUnit_Name; | |||
| if dmo.AccountingUnit_ID==5: | |||
| voucher2.Head.VoucherType = "QHC凭证"; | |||
| else: | |||
| voucher2.Head.VoucherType = "记账凭证"; | |||
| voucher2.Head.FiscalYear = self.proxy.GetDateTime(gToday,"yyyy"); | |||
| voucher2.Head.AccountingPeriod = self.proxy.GetDateTime(gToday,"MM"); | |||
| voucher2.Head.Date = self.proxy.GetDateTime(gToday,"yyyy-MM-dd"); | |||
| voucher2.Head.Signature = "Y"; | |||
| voucher2.Head.VoucherMakingSystem = "总账"; | |||
| voucher2.Head.Reserve2 = "N"; | |||
| voucher2.Head.Enter = gUser.Name; | |||
| voucher2.Head.VoucherId = "0"; | |||
| voucher2.Head.AttachmentNumber = "0"; | |||
| vouchers.Bills.Add(voucher2); | |||
| entryid = 0; | |||
| for dmo in dmos: | |||
| if dmo.AccountingUnit_ID == 1: | |||
| entryid = entryid + 1; | |||
| entry = NcVoucherEntry(); | |||
| voucher2.Body.Entrys.Add(entry); | |||
| entry.EntryId = str(entryid); | |||
| entry.AccountCode = "原材料生猪" ; | |||
| weight = self.proxy.GetSumWeight(dmo.Details); | |||
| entry.Abstract = self.proxy.GetStatPayDate(dmo,"yyyy-MM-dd")+dmo.Supplier_Name +"购买生猪"+ self.proxy.GetSumNumber(dmo.Details)+ "头"+weight+"KG"; | |||
| entry.Currency = "CNY"; | |||
| entry.ExchangeRate2 = "1" ; | |||
| debitAmount = self.proxy.GetSumMoney(dmo.Details); | |||
| entry.PrimaryDebitAmount = debitAmount; | |||
| entry.NaturalDebitCurrency = debitAmount; | |||
| entry.DebitQuantity = weight; | |||
| entry.UnitPrice = str(dmo.Details[0].CheckTareWeightPrice); | |||
| for dmo in dmos: | |||
| if dmo.AccountingUnit_ID == 1: | |||
| entryid = entryid + 1; | |||
| weight = self.proxy.GetSumWeight(dmo.Details); | |||
| abstract = self.proxy.GetStatPayDate(dmo,"yyyy-MM-dd")+dmo.Supplier_Name +"购买生猪"+ self.proxy.GetSumNumber(dmo.Details)+ "头"+weight+"KG"; | |||
| entry = NcVoucherEntry(); | |||
| voucher2.Body.Entrys.Add(entry); | |||
| entry.EntryId = str(entryid); | |||
| entry.AccountCode = "集团外应付生猪款" ; | |||
| entry.Abstract = abstract; | |||
| entry.Currency = "CNY"; | |||
| entry.ExchangeRate2 = "1" ; | |||
| entry.PrimaryCreditAmount = self.proxy.GetSumMoney(dmo.Details); | |||
| entry.NaturalCreditCurrency = self.proxy.GetSumMoney(dmo.Details); | |||
| item =Items(); | |||
| item.Name = "供应商辅助核算"; | |||
| item.Value = dmo.Supplier_Name; | |||
| entry.Accountings.Items.Add(item); | |||