/// <summary>
 /// 保存采购收货
 /// </summary>
 /// <param name="data">前端采购收货数据</param>
 /// <returns>处理状态响应</returns>
 public static bool SavePurchaseReceipt(PurchaseReceiptData data)
 {
     try
     {
         if (data.lines == null || data.lines.Count == 0)
         {
             return(false);
         }
         CompanyAddress company = Common.CompanyHelper.GetCompanyAddress(data.companyGuid);
         if (company == null)
         {
             throw new Exception("Aden.BLL.Common.CompanyHelper.GetCompanyAddress doesn't exist companyGuid:" + data.companyGuid);
         }
         string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
         return(factory.AddPurchaseReceipt(data.lines, company.erpCode, data.receiptDate, data.warehouseCode, data.supplierCode, data.poType,
                                           data.userGuid, now));
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog(new Log()
         {
             message = ex.Message
         }, "SavePurchaseReceipt");
         return(true);
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new InvalidArgumentsException("Token is missing");
            }

            Auth = new VismaNetAuthorization
            {
                Token     = token,
                CompanyId = companyId,
                BranchId  = branchId
            };
            Attribute                = new AttributeData(Auth);
            Customer                 = new CustomerData(Auth);
            Currency                 = new CurrencyData(Auth);
            CustomerInvoice          = new CustomerInvoiceData(Auth);
            Supplier                 = new SupplierData(Auth);
            SupplierInvoice          = new SupplierInvoiceData(Auth);
            CashSale                 = new CashSaleData(Auth);
            CustomerDocument         = new CustomerDocumentData(Auth);
            Dimension                = new DimensionData(Auth);
            Discount                 = new DiscountData(Auth);
            Inventory                = new InventoryData(Auth);
            JournalTransaction       = new JournalTransactionData(Auth);
            GeneralLedgerTransaction = new GeneralLedgerTransactionData(Auth);
            GeneralLedgerBalance     = new GeneralLedgerBalanceData(Auth);
            Account         = new FinAccountData(Auth);
            FinancialPeriod = new FinancialPeriodData(Auth);
            Employee        = new EmployeeData(Auth);
            Shipment        = new ShipmentData(Auth);
            Contact         = new ContactData(Auth);
            Project         = new ProjectData(Auth);
#pragma warning disable CS0618 // Type or member is obsolete
            SalesOrder = new SalesOrderData(Auth);
#pragma warning restore CS0618 // Type or member is obsolete
            Branch             = new BranchData(Auth);
            Warehouse          = new WarehouseData(Auth);
            Location           = new LocationData(Auth);
            Subaccount         = new SubaccountData(Auth);
            CustomerPayment    = new CustomerPaymentData(Auth);
            Dynamic            = new VismaNetDynamicEndpoint(null, Auth);
            Resources          = new VismaNetDynamicEndpoint(null, Auth, true);
            SupplierDocument   = new SupplierDocumentData(Auth);
            InventoryIssue     = new InventoryIssueData(Auth);
            InventoryReceipt   = new InventoryReceiptData(Auth);
            PurchaseReceipt    = new PurchaseReceiptData(Auth);
            CustomerSalesPrice = new CustomerSalesPriceData(Auth);
            CustomerCreditNote = new CustomerCreditNoteData(Auth);
            PurchaseOrder      = new PurchaseOrderData(Auth);
            CashTransaction    = new CashTransactionData(Auth);
        }
        public Response SaveReceipt(string token, [FromBody] PurchaseReceiptData receiptData)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code = "404";
                response.message = "Invild token";
            }
            else
            {
                bool status = PurchaseHelper.SavePurchaseReceipt(receiptData);
                if (status) response.code = "200";
                else
                {
                    response.code = "500";
                    response.message = "process failed";
                }
            }
            return response;
        }