예제 #1
0
        /// <summary>
        /// Get tax documment from 1C 7.7
        /// </summary>
        /// <param name="global">handle to global module 1C 7.7</param>
        /// <param name="Doc">Handle to tax document in 1C 7.7</param>
        /// <param name="ConfigType">Configuration 1C 7.7 enum</param>
        /// <param name="org">Organization reference</param>
        public static J1201010 GetFrom1C77(GlobalObject1C77 global, COMObject doc, IOrganization org)
        {
            J1201010 result = org.IS_NP?new J1201010():new F1201010();

            // шапка налоговой
            result.TIN = Get1C77_HKSEL(doc, org);
            //result.C_DOC
            //result.C_DOC_SUB
            //result.C_DOC_VER
            result.C_DOC_TYPE = 0;
            result.C_REG      = org.C_REG;
            result.C_RAJ      = org.C_RAJ;
            var str = doc.GetPropertyString("DocNum");

            try
            {
                var str1 = (new string(str.Where(s => Char.IsDigit(s)).ToArray())).TrimStart('0');
                result.C_DOC_CNT = uint.Parse(str1);
            }
            catch
            {
                string error = $"Error parse tax number {str} as uint";
                Trace.TraceError(error);
                throw new Exception(error);
            }
            result.PERIOD_TYPE = 1;
            DateTime date = doc.GetPropertyDateTime("DocDate");

            result.PERIOD_YEAR  = date.Year;
            result.PERIOD_MONTH = date.Month;
            result.D_FILL       = DateTime.Now;


            result.R01G1    = new int?();
            result.R03G10S  = Get1C77_R03G10S(doc, org);
            result.HORIG1   = new int?();
            result.HTYPR    = new DGPNtypr?();
            result.HKSEL    = Get1C77_HKSEL(doc, org);
            result.HNAMESEL = Get1C77_HNAMESEL(doc, org);
            result.HTINSEL  = Get1C77_TINSEL(doc, org);
            result.HNUM2    = org.FilialNumber == ""?null: org.FilialNumber;
            result.HFILL    = date.DateToOPZFormat();
            result.HNUM     = result.C_DOC_CNT;
            result.HNUM1    = new ulong?();
            result.HNAMEBUY = Get1C77_HNAMEBUY(doc, org);
            result.HKBUY    = Get1C77_HKBUY(doc, org);
            result.HFBUY    = Get1C77_HFBUY(doc, org);
            result.HTINBUY  = Get1C77_HTINBUY(doc, org);

            result.HBOS  = org.Manager;
            result.HKBOS = org.ManagerIPN;

            if (doc.MethodDouble("SelectLines") == 1)
            {
                while (doc.MethodDouble("GetLine") == 1)
                {
                    //DateTime DataDoc = Doc.Property("ДатаДок").ToDateTime();
                    //if (OLE.IsEmtyValue(Doc.Property("ТМЦ"))) continue;
                    J1201010T1 t1 = new J1201010T1();


                    t1.RXXXXG3S = Get1C77_TmcDescription(doc, org); //ТМЦ
                    if (doc.Is1C77_usluga(org))
                    {
                        t1.RXXXXG33 = doc.Get1C77_UKTZED(org);
                    }
                    else
                    {
                        t1.RXXXXG4 = doc.Get1C77_UKTZED(org);
                    }

                    t1.RXXXXG4S     = doc.GetPropertyObject("Ед").GetPropertyString("Наименование"); // UnitOfMeasure
                    t1.RXXXXG105_2S = Get1C77_UnitCode(doc, org);

                    t1.RXXXXG5 = Get1C77_quantity(doc, org);

                    t1.RXXXXG6 = Get1C77_CostWithoutVAT(doc, org);

                    t1.RXXXXG008   = Get1C77_StavkaNDS(doc, org);
                    t1.RXXXXG009   = Get1C77_PilgaNDS(doc, org);
                    t1.RXXXXG010   = Get1C77_SumWithoutVAT(doc, org);
                    t1.RXXXXG11_10 = new decimal?((decimal)doc.Get1C77_VAT(org));
                    result.T1.Add(t1);
                }
            }
            return(result);
        }