Ejemplo n.º 1
0
        public SalesDocumentNode CreateSalesDocument(Order order)
        {
            var exportSaleDocument = new SalesDocumentNode {
                Id = ++objectCounter
            };

            exportSaleDocument.Reference = new ReferenceNode(exportSaleDocument.Id,
                                                             new PropertyNode("Номер", Common1cTypes.String, ExportMode == Export1cMode.IPForTinkoff ? order.OnlineOrder.Value : order.Id),
                                                             new PropertyNode("Дата", Common1cTypes.Date, order.DeliveryDate.Value.ToString("s"))
                                                             );

            var exportGoodsTable = new TableNode {
                Name = "Товары",
            };

            var exportServicesTable = new TableNode {
                Name = "Услуги",
            };

            foreach (var orderItem in order.OrderItems)
            {
                var record = CreateRecord(orderItem);
                if (Nomenclature.GetCategoriesForGoods().Contains(orderItem.Nomenclature.Category))
                {
                    exportGoodsTable.Records.Add(record);
                    exportSaleDocument.Comission.Comissions.Add(0);
                }
                else
                {
                    exportServicesTable.Records.Add(record);
                }
            }

            exportSaleDocument.Properties.Add(
                new PropertyNode("Организация",
                                 Common1cTypes.ReferenceOrganization,
                                 OrganizationCatalog.CreateReferenceTo(order.Contract.Organization)
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("Комментарий",
                                 Common1cTypes.String,
                                 order.Comment
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("Склад",
                                 Common1cTypes.ReferenceWarehouse,
                                 WarehouseCatalog.CreateReferenceTo(Warehouse1c.Default)
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("Контрагент",
                                 Common1cTypes.ReferenceCounterparty,
                                 CounterpartyCatalog.CreateReferenceTo(order.Client)
                                 )
                );

            exportSaleDocument.Properties.Add(
                new PropertyNode("ДоговорКонтрагента",
                                 Common1cTypes.ReferenceContract,
                                 ContractCatalog.CreateReferenceToContract(order)
                                 )
                );

            exportSaleDocument.Properties.Add(
                new PropertyNode("ВалютаДокумента",
                                 Common1cTypes.ReferenceCurrency,
                                 CurrencyCatalog.CreateReferenceTo(ExportTo1c.Currency.Default)
                                 )
                );

            exportSaleDocument.Properties.Add(
                new PropertyNode("СуммаВключаетНДС",
                                 Common1cTypes.Boolean,
                                 "true"
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("ВидОперации",
                                 "ПеречислениеСсылка.ВидыОперацийРеализацияТоваров",
                                 "ПродажаКомиссия"
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("КурсВзаиморасчетов",
                                 Common1cTypes.Numeric,
                                 1
                                 )
                );
            exportSaleDocument.Properties.Add(
                new PropertyNode("КратностьВзаиморасчетов",
                                 Common1cTypes.Numeric,
                                 1
                                 )
                );

            exportSaleDocument.Tables.Add(exportGoodsTable);
            exportSaleDocument.Tables.Add(exportServicesTable);
            return(exportSaleDocument);
        }
Ejemplo n.º 2
0
        public void AddOrder(Order order)
        {
            OrdersTotalSum += order.OrderSum;
            if (order.PaymentType == PaymentType.ByCard || order.PaymentType == PaymentType.cash || order.PaymentType == PaymentType.Terminal)
            {
                CreateRetailDocument(order);
            }
            else
            {
                var exportSalesDocument   = CreateSalesDocument(order);
                var exportInvoiceDocument = new InvoiceDocumentNode {
                    Id = ++objectCounter
                };
                exportInvoiceDocument.Reference = new ReferenceNode(exportInvoiceDocument.Id,
                                                                    new PropertyNode("Номер", Common1cTypes.String, ExportMode == Export1cMode.IPForTinkoff ? order.OnlineOrder.Value : order.Id),
                                                                    new PropertyNode("Дата", Common1cTypes.Date, order.DeliveryDate.Value.ToString("s"))
                                                                    );

                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("Организация",
                                     Common1cTypes.ReferenceOrganization,
                                     OrganizationCatalog.CreateReferenceTo(order.Contract.Organization)
                                     )
                    );

                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("Комментарий",
                                     Common1cTypes.String
                                     )
                    );

                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ДоговорКонтрагента",
                                     Common1cTypes.ReferenceContract,
                                     ContractCatalog.CreateReferenceToContract(order)
                                     )
                    );

                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ДокументОснование",
                                     "ДокументСсылка.РеализацияТоваровУслуг",
                                     exportSalesDocument.Reference
                                     )
                    );

                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ВидСчетаФактуры",
                                     Common1cTypes.EnumInvoiceType,
                                     "НаРеализацию"
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("НомерПлатежноРасчетногоДокумента",
                                     Common1cTypes.String
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ДатаПлатежноРасчетногоДокумента",
                                     Common1cTypes.Date
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ВалютаДокумента",
                                     Common1cTypes.ReferenceCurrency,
                                     CurrencyCatalog.CreateReferenceTo(Currency.Default)
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("СтавкаНДС",
                                     Common1cTypes.EnumVAT
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("Сумма",
                                     Common1cTypes.Numeric
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("СуммаНДС",
                                     Common1cTypes.Numeric
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("Контрагент",
                                     Common1cTypes.ReferenceCounterparty,
                                     CounterpartyCatalog.CreateReferenceTo(order.Client)
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("ПометкаУдаления",
                                     Common1cTypes.Boolean
                                     )
                    );
                exportInvoiceDocument.Properties.Add(
                    new PropertyNode("Проведен",
                                     Common1cTypes.Boolean,
                                     "true"
                                     )
                    );
                Objects.Add(exportSalesDocument);
                Objects.Add(exportInvoiceDocument);
            }
        }