Example #1
0
        public TableRecordNode CreateRetailRecord(OrderItem orderItem)
        {
            var  record                = new TableRecordNode();
            bool isService             = false;
            var  nomenclatureReference = NomenclatureCatalog.CreateReferenceTo(orderItem.Nomenclature);

            record.Properties.Add(
                new PropertyNode("Номенклатура",
                                 Common1cTypes.ReferenceNomenclature,
                                 nomenclatureReference
                                 )
                );
            record.Properties.Add(
                new PropertyNode(
                    "Количество",
                    Common1cTypes.Numeric,
                    orderItem.CurrentCount
                    )
                );

            record.Properties.Add(
                new PropertyNode("Цена",
                                 Common1cTypes.Numeric,
                                 orderItem.Price));

            ExportedTotalSum += orderItem.ActualSum;

            record.Properties.Add(
                new PropertyNode(
                    "Сумма",
                    Common1cTypes.Numeric,
                    orderItem.ActualSum
                    )
                );

            var vat = VAT.No.GetAttribute <Value1c>().Value;

            record.Properties.Add(
                new PropertyNode("СтавкаНДС",
                                 Common1cTypes.EnumVAT,
                                 vat
                                 )
                );

            record.Properties.Add(
                new PropertyNode("СуммаНДС",
                                 Common1cTypes.Numeric
                                 )
                );

            return(record);
        }
Example #2
0
        public TableRecordNode CreateRecord(OrderItem orderItem)
        {
            var  record                = new TableRecordNode();
            bool isService             = !Nomenclature.GetCategoriesForGoods().Contains(orderItem.Nomenclature.Category);
            var  nomenclatureReference = NomenclatureCatalog.CreateReferenceTo(orderItem.Nomenclature);

            record.Properties.Add(
                new PropertyNode("Номенклатура",
                                 Common1cTypes.ReferenceNomenclature,
                                 nomenclatureReference
                                 )
                );
            if (isService)
            {
                record.Properties.Add(
                    new PropertyNode("Содержание",
                                     Common1cTypes.String,
                                     orderItem.Nomenclature.OfficialName
                                     )
                    );
            }
            record.Properties.Add(
                new PropertyNode(
                    "Количество",
                    Common1cTypes.Numeric,
                    orderItem.CurrentCount
                    )
                );
            if (!isService)
            {
                record.Properties.Add(
                    new PropertyNode("Коэффициент",
                                     Common1cTypes.Numeric,
                                     1
                                     )
                    );
            }

            record.Properties.Add(
                new PropertyNode("Цена",
                                 Common1cTypes.Numeric,
                                 orderItem.Price));

            ExportedTotalSum += orderItem.ActualSum;

            record.Properties.Add(
                new PropertyNode(
                    "Сумма",
                    Common1cTypes.Numeric,
                    orderItem.ActualSum
                    )
                );

            var vat = orderItem.Nomenclature.VAT.GetAttribute <Value1c>().Value;

            record.Properties.Add(
                new PropertyNode("СтавкаНДС",
                                 Common1cTypes.EnumVAT,
                                 vat
                                 )
                );

            if (orderItem.Nomenclature.VAT != VAT.No)
            {
                record.Properties.Add(
                    new PropertyNode(
                        "СуммаНДС",
                        Common1cTypes.Numeric,
                        orderItem.IncludeNDS ?? 0                         //FIXME Нужно будет сделать что бы всегда соответствало количетству.
                        )
                    );
            }
            else
            {
                record.Properties.Add(
                    new PropertyNode("СуммаНДС",
                                     Common1cTypes.Numeric
                                     )
                    );
            }

            if (!isService)
            {
                record.Properties.Add(
                    new PropertyNode("НомерГТД",
                                     "СправочникСсылка.НомераГТД"
                                     )
                    );
                record.Properties.Add(
                    new PropertyNode("СтранаПроисхождения",
                                     Common1cTypes.ReferenceCountry
                                     )
                    );
            }
            return(record);
        }
Example #3
0
        public void CreateRetailDocument(Order order)
        {
            if (!order.DeliveryDate.HasValue)
            {
                throw new ArgumentNullException(nameof(order.DeliveryDate));
            }

            if (!RetailDocumentsList.TryGetValue(order.DeliveryDate.Value.Date, out RetailDocumentNode exportRetailDocument))
            {
                exportRetailDocument = new RetailDocumentNode {
                    Id = ++objectCounter
                };

                exportRetailDocument.Reference = new ReferenceNode(
                    exportRetailDocument.Id,
                    new PropertyNode(
                        "Номер",
                        Common1cTypes.String,
                        ExportMode == Export1cMode.IPForTinkoff ? (order.OnlineOrder ?? throw new ArgumentNullException(nameof(order.OnlineOrder), $@"(OrderId: {order.Id})")) : order.Id),
                    new PropertyNode(
                        "Дата",
                        Common1cTypes.Date,
                        order.DeliveryDate.Value.Date.ToString("s"))
                    );

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

                var exportRefundGoodsTable = new TableNode
                {
                    Name = "Возвраты",
                };

                var exportTerminalTable = new TableNode
                {
                    Name = "Оплата",
                };

                var exportRefundTerminalTable = new TableNode
                {
                    Name = "ВозвратОплаты",
                };

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

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

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

                exportRetailDocument.Tables.Add(exportGoodsTable);
                exportRetailDocument.Tables.Add(exportTerminalTable);
                exportRetailDocument.Tables.Add(exportRefundGoodsTable);
                exportRetailDocument.Tables.Add(exportRefundTerminalTable);
            }

            bool isTerminalPaid = (order.PaymentType == PaymentType.ByCard || order.PaymentType == PaymentType.Terminal);

            bool isRefund = false;

            foreach (var orderItem in order.OrderItems)
            {
                isRefund = (orderItem.ActualSum < 0);

                if (orderItem.ActualSum != 0)
                {
                    var record = CreateRetailRecord(orderItem);

                    exportRetailDocument.Tables[0].Records.Add(record);                     //Товары

                    if (isRefund)
                    {
                        exportRetailDocument.Tables[2].Records.Add(record);
                    }

                    if (isTerminalPaid)
                    {
                        var recordPayment = new TableRecordNode();
                        recordPayment.Properties.Add(
                            new PropertyNode("СуммаОплаты",
                                             Common1cTypes.Numeric,
                                             orderItem.ActualSum
                                             )
                            );                    //оплаты безналом
                        exportRetailDocument.Tables[1].Records.Add(recordPayment);

                        if (isRefund)
                        {
                            exportRetailDocument.Tables[3].Records.Add(recordPayment);
                        }
                    }
                }
            }

            if (!RetailDocumentsList.ContainsKey(order.DeliveryDate.Value.Date))
            {
                RetailDocumentsList.Add(order.DeliveryDate.Value.Date, exportRetailDocument);
            }
        }