diff --git a/BWP.B3ButcherManageExport/BL/NC/StatPayToNcBL_/StatPayToNcBL.cs b/BWP.B3ButcherManageExport/BL/NC/StatPayToNcBL_/StatPayToNcBL.cs index 95b480b..e872123 100644 --- a/BWP.B3ButcherManageExport/BL/NC/StatPayToNcBL_/StatPayToNcBL.cs +++ b/BWP.B3ButcherManageExport/BL/NC/StatPayToNcBL_/StatPayToNcBL.cs @@ -7,6 +7,7 @@ using Forks.EnterpriseServices; using Forks.EnterpriseServices.BusinessInterfaces; using System; using System.Collections.Generic; +using System.Linq; using TSingSoft.WebPluginFramework; using TSingSoft.WebPluginFramework.BIPlugins.BLEvents; @@ -57,5 +58,15 @@ namespace BWP.B3ButcherManageExport.BL Date = date ?? BLContext.Today; Export(dmoIDs, extSystemID); } + + public void CheckAccountingUnit(IEnumerable dmos) + { + var groups = dmos.GroupBy(x => x.AccountingUnit_Name); + var count = groups.Count(); + if (count > 1) + { + throw new ApplicationException("一次导出只能选择同一个会计单位下的单据"); + } + } } } diff --git a/BWP.B3ButcherManageExport/BL/NC/script/大红门结算单导NC凭证.py b/BWP.B3ButcherManageExport/BL/NC/script/大红门结算单导NC凭证.py index 952d1c7..6846a15 100644 --- a/BWP.B3ButcherManageExport/BL/NC/script/大红门结算单导NC凭证.py +++ b/BWP.B3ButcherManageExport/BL/NC/script/大红门结算单导NC凭证.py @@ -21,12 +21,13 @@ class BLMethodEvents(BLMethodEventsBase): def execute(self): self.proxy.CheckAccountingUnit(dmos); - voucher2 = NcVoucher(); + voucher2 = NcVoucher(); for dmo in dmos: voucher2.B2BillIDs.Add(dmo.ID); - voucher2.Head.Company = dmo.AccountingUnit_Name; - if dmo.AccountingUnit_ID==5: + statePay = dmos[0]; + voucher2.Head.Company = statePay.AccountingUnit_Name; + if statePay.AccountingUnit_ID==5: voucher2.Head.VoucherType = "QHC凭证"; else: voucher2.Head.VoucherType = "记账凭证"; @@ -42,16 +43,16 @@ class BLMethodEvents(BLMethodEventsBase): vouchers.Bills.Add(voucher2); entryid = 0; - num = str(dmo.RealNumber); - weight = str(dmo.RealWeight); - abstract = self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd")+dmo.Supplier_Name +"购买生猪"+ num + "头"+ weight +"KG"; for dmo in dmos: + num = str(dmo.RealNumber); + weight = str(dmo.RealWeight); + abstract = self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd")+dmo.Supplier_Name +"购买生猪"+ num + "头"+ weight +"KG"; if dmo.AccountingUnit_ID == 1: entryid = entryid + 1; entry = NcVoucherEntry(); voucher2.Body.Entrys.Add(entry); entry.EntryId = str(entryid); - entry.AccountCode = "原材料\生猪" ; + entry.AccountCode = "原材料生猪" ; entry.Abstract = abstract; entry.Currency = "CNY"; entry.ExchangeRate2 = "1" ; @@ -60,22 +61,9 @@ class BLMethodEvents(BLMethodEventsBase): entry.DebitQuantity = weight; entry.UnitPrice = str(dmo.RawPrice); 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 = "预付账款\集团外预付账款\其他预付生猪款" ; - entry.Abstract = abstract; - entry.Currency = "CNY"; - entry.ExchangeRate2 = "1" ; - entry.PrimaryCreditAmount = str(dmo.Money); - entry.NaturalCreditCurrency = str(dmo.Money); - item =Items(); - item.Name = "供应商辅助核算"; - item.Value = dmo.Supplier_Name; - entry.Accountings.Items.Add(item); - for dmo in dmos: + num = str(dmo.RealNumber); + weight = str(dmo.RealWeight); + abstract = self.proxy.GetDateTime(dmo.Date,"yyyy-MM-dd")+dmo.Supplier_Name +"购买生猪"+ num + "头"+ weight +"KG"; if dmo.AccountingUnit_ID == 1: entryid = entryid + 1; entry = NcVoucherEntry();