Subject: RS
From: Zurab Batiashvili
To: "[email-masked]<[email-masked]>" <[email-masked]>, [email-masked], "[email-masked]<[email-masked]>" <[email-masked]>, [email-masked]
Date: Fri, 16 Jun 2017 08:57:00 +0000

ამ მეთოდს მოაქვს

var zednadebi = new InvoisebisSacavi().MomeciZednadebiPrintistvis(invoisisid);

რაც იტვირთება RS-ზე

{

InvoisisId = g.G.Key,

InvoisisNomeri = g.First.First().InvoisisNomeri,

InvoisisTipi = g.First.First().InvoisisTipi,

GamcemiObiekti = g.First.First().OBJ_IN_NAME,

GamcemiObiektisTAX = g.First.First().OBJ_IN_TAX,

GamcemiObiektisMisamarti = g.First.First().OBJ_IN_ADDRESS,

GamcemiObieqtisLicenzia = g.First.First().GamcemisLicenzia,

MimgebiObiekti = g.First.First().OBJ_OUT_NAME,

MimgebiObiektiTAX = g.First.First().OBJ_OUT_TAX,

MimgebiObiektiMisamarti = g.First.First().OBJ_OUT_ADDRESS,

MimgebiObieqtisLicenzia = g.First.First().MimgebisLicenzia,

OperaciisTarigi = g.First.First().OperaciisTarigi,

Manqana = g.First.First().Manqana,

Shoferi = g.First.First().Shoferi,

Safuzveli = g.First.First().Safuzveli,

AtvirtuliaRs = g.First.First().RS_Atvirtulia != 0,

ZednadebisCamlebi = g.First

// .GroupBy(y => y.CamlisId)

//.Select(y => new { GCamlis = y, FirstCamlis = y.Select(p => p) })

.Select(p => new ZednadebisCamali()

{

CamlisDasaxeleba = p.NAME,

CamlisSeria = p.DRUG_SERIAL_NO,

ZomisErteuli = p.DRUG_PACKING,

Raodenoba = p.QUANTITY,

VargisianobisVada = p.DRUGV_VALID_TO.ToString("dd/MM/yyyy"),

ErteulisFasi = p.PRICE,

McarmoebeliQvekana = p.MAKER_COUNTRY,

McarmoebeliFirma = p.MAKER,

RegistraciisNomeri = p.REGISTER_NO

}

)

.OrderBy(t => t.CamlisDasaxeleba)

.ToList()

}

zednadebi.InvoisisNomeri = invoisisNomeri;

zednadebi.InvoisisTipi = invoisisTipi;

zednadebi.Manqana = manqana.ToUpper().Trim();

zednadebi.Shoferi = shoferi.Trim();

zednadebi.Safuzveli = safuzveli;

private ZednadebisAtvirtvisShedegisModel AtvirteZednadebi_V02(ShidaBrunvisZednadebiPrintModeli zednadebi,

string userName, string userPassword, string iP, int rSUserId, int rSUnId)

{

// const string su = "zurabbat:202178927";

var su = userName.ToUpper();

//const string sp = "123456";

var sp = userPassword;

int erteulisInt;

var transportirebit = zednadebi.Manqana != "AAA000" & zednadebi.Shoferi != "00000000000";

using (var cl = new sr_RS.WayBillsSoapClient())

{

var zednadebisTipebi = new Infrastruqtura.RS.RS_Enumebi().ZednadebisTipebi;

var xmlNode = new XElement(

new XElement("WAYBILL",

new XElement("SUB_WAYBILLS", ""),

new XElement("ID", "0"),

new XElement("TYPE", "1"), // "შიდა გადაზიდვა"

new XElement("BUYER_TIN", "202178927"), //zednadebi.MimgebiObiektiTAX.Trim()

new XElement("CHEK_BUYER_TIN", "1"),

new XElement("BUYER_NAME", "სსიპ სოციალური მომსახურების სააგენტო" /* zednadebi.MimgebiObiekti */),

new XElement("START_ADDRESS", zednadebi.GamcemiObiektisMisamarti),

new XElement("END_ADDRESS", zednadebi.MimgebiObiektiMisamarti),

new XElement("DRIVER_TIN", transportirebit ? zednadebi.Shoferi : ""), // ********     roca transportirebitaaa

new XElement("CHEK_DRIVER_TIN", "1"),

new XElement("DRIVER_NAME", ""),

new XElement("TRANSPORT_COAST", "0"),

new XElement("RECEPTION_INFO", zednadebi.GamcemiObiekti),

new XElement("RECEIVER_INFO", zednadebi.MimgebiObiekti),

new XElement("DELIVERY_DATE", string.Format("{0:yyyy-MM-dd}T18:00:15", zednadebi.OperaciisTarigi)),

new XElement("STATUS", "1"),

new XElement("SELER_UN_ID", rSUnId), //"1149251"),// 1149251 rSUserId

new XElement("PAR_ID", ""),

new XElement("FULL_AMOUNT", zednadebi.InvoisisFasi.ToString()),

new XElement("CAR_NUMBER", transportirebit ? zednadebi.Manqana : ""), //************ roca transportirebitaaa

new XElement("S_USER_ID", rSUserId), //"31888"), //1149251 rSUserId

new XElement("BEGIN_DATE", string.Format("{0:yyyy-MM-dd}T09:30:15", zednadebi.OperaciisTarigi)),

new XElement("TRAN_COST_PAYER", "1"),

new XElement("TRANS_ID", transportirebit ? "1" : "4"), // 1 - საავტომობილო , 4 - სხვა

new XElement("TRANS_TXT", transportirebit ? "" : "სხვა"),

new XElement("COMMENT", "")

));

var xGoogs = new XElement("GOODS_LIST");

foreach (var camali in zednadebi.ZednadebisCamlebi)

{

xGoogs.Add(new XElement("GOODS",

new XElement("ID", "0"),

new XElement("W_NAME", camali.CamlisDasaxeleba),

new XElement("UNIT_ID", //"99"

Enum.IsDefined(typeof(RS_Enumebi.ZednadebisZomisErteulebi), camali.ZomisErteuli.Trim()) ?

(int)(RS_Enumebi.ZednadebisZomisErteulebi)Enum.Parse(typeof(RS_Enumebi.ZednadebisZomisErteulebi), camali.ZomisErteuli.Trim(), true) :

99),

new XElement("UNIT_TXT", camali.ZomisErteuli.Trim()),

new XElement("QUANTITY", camali.Raodenoba),

new XElement("PRICE", camali.ErteulisFasi),

new XElement("STATUS", "1"),

new XElement("AMOUNT", camali.SulFasi),

new XElement("BAR_CODE", ""),

new XElement("A_ID", "0"),

new XElement("VAT_TYPE", "1")));

}

xmlNode.Add(xGoogs);

var shedegi = cl.save_waybill(su, sp, xmlNode);

var rrr = shedegi.Element("STATUS") == null ? "NULL" : shedegi.Element("STATUS").Value;

if (rrr != "0")

{

var stream = GetType().Assembly.GetManifestResourceStream("Camlebi.Infrastruqtura.RS.RS_Error_List.xml");

var atvirtvisShedegi =

(from x in XElement.Load(stream).Elements("ERROR_CODE")

where x.Element("ID").Value == rrr

select x).First().Element("TEXT").Value;

return new ZednadebisAtvirtvisShedegisModel()

{

Shecdoma = atvirtvisShedegi,

Status = int.Parse(rrr),

ZednadebisNomeri = "0"

};

}

return new ZednadebisAtvirtvisShedegisModel()

{

Shecdoma = "აიტვირთა წარმატებით",

Status = int.Parse(rrr),

ZednadebisNomeri = shedegi.Element("WAYBILL_NUMBER").Value

};

}

}