Skip to content

Instantly share code, notes, and snippets.

@stdray
Created July 28, 2015 20:21
Show Gist options
  • Select an option

  • Save stdray/68db2b8896cc42de3cbf to your computer and use it in GitHub Desktop.

Select an option

Save stdray/68db2b8896cc42de3cbf to your computer and use it in GitHub Desktop.
[Overloads(src, Actual.zfcs_contract2015Type, Actual.zfcs_contractType
, Version_5_0.zfcs_contractType, Version_5_0.zfcs_contract2015Type
, Version_4_6.zfcs_contractType
, Version_4_3_1211.zfcs_contractType)]
public Contract(src : zfcs_contract2015Type) : ContractType
{
def foundation = foundationInfo(src.foundation);
def item = src.modification.ItemChoice;
def change = choice(item)
{
when(item.contractChange(x))
x;
when(item.errorCorrection(_))
null
}
entity <-
{
def attachments = from a in src.attachments select attachment(a);
def medicalDocuments = from a in src.medicalDocuments select attachment(a);
def scanDocuments = from a in src.scanDocuments select attachment(a);
Attachments = foundation.Attachments +++ attachments +++ medicalDocuments +++ scanDocuments;
Budget <-
{
def budgetFunds = src.finances.budgetFunds;
BudgetFinancings =
from (stage in budgetFunds.stages, payment in stage.payments)
select entity <-
{
Comment = payment.comment;
EndStageDate = date(stage.endDate);
KBK = payment.KBK;
PaymentsSum = decimal'(payment.paymentSumRUR);
}
BudgetInfo = budgetFunds?.budget.name;
BudgetLevelType = budgetLevel(budgetFunds.budgetLevel);
//DamagePaymentsSum = change.damagePayments
def extrabudgetFunds = src.finances.extrabudgetFunds;
NonBudgeFinancings =
from (stage in extrabudgetFunds.stages, payment in stage.payments)
select entity <-
{
Comment = payment.comment;
EndStageDate = date(stage.endDate);
KOSGU = payment.KOSGU;
PaymentsSum = decimal'(payment.paymentSumRUR);
}
NonBudgetInfo = extrabudgetFunds.extrabudget.name;
SubSupplierSum = decimal'(src.subContractorsSum.priceValueRUR);
}
ExternalLinks = entity when(foundation.TenderNumber != null) <-
{
Lot <-
{
LotNumber = str(foundation.LotNumber);
TenderIdentity = foundation.TenderNumber;
}
}
IdentityInfo <-
{
ContractIdentity = src.regNum;
}
MainInfo <-
{
def price = src.priceInfo;
ContractPrice = decimal'(price.price);
ContractPriceDefinition = priceDefinition(price.priceType);
CreationDate = date(src.publishDate);
Currency = price.currency?.code;
EndExecutionDate = date(src.executionPeriod.endDate);
Foundation = foundation.Foundation;
PlacingWay = foundation.Placing;
SignDate = date(src.signDate);
StartExecutionDate = date(src.executionPeriod.startDate);
}
OptionalInfo <-
{
ContractCode = src.documentCode;
def reason = change?.reason;
IsPriceChanged = nullable(reason != null);
IsSingleSeller = foundation.IsSingleSeller;
PriceChangedReason = reason?.name;
SingleSellerReason = foundation.SingleSellerReason;
}
Participants = collection
{
participant(person(src.customer), ContractTypeParticipantRole.Customer);
}
Products =
from product in src.products.product
select entity <-
{
AmountUnit = product.OKEI.code;
Classifiers = collection entity <-
{
Code = product.OKPD.code;
Name = product.OKPD.name;
Type = ClassiferType.OKPD;
}
LocalIdentity = str(Guid.NewGuid());
Name = product.name;
TotalPrice = decimal'(product.sumRUR) ?? decimal'(product.sum);
TotalQuantity = decimal'(product.quantity);
UnitPrice = decimal'(product.priceRUR) ?? decimal'(product.price);
}
PublishInfo <-
{
Date = date(src.publishDate);
Url = src.href;
Version = str(src.versionNumber);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment