Фикс оплаты по виду сделки
This commit is contained in:
parent
7df93dc822
commit
6a8c7a57a9
@ -3,6 +3,7 @@ using _1CDataBus.Structure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Simple.OData.Client;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
@ -37,13 +38,37 @@ namespace _1CDataBus.Controllers
|
||||
.Expand("BusinessUnit")
|
||||
.Expand("Counterparty")
|
||||
.Expand("Currency")
|
||||
.Expand("DealKindSungero")
|
||||
.FindEntryAsync();
|
||||
var sendContract = new Contract(contract);
|
||||
await SendContractTo1C(sendContract);
|
||||
}
|
||||
|
||||
//[HttpPost("Test")]
|
||||
//public async Task TestDelete()
|
||||
//{
|
||||
// var peoples = await _client
|
||||
// .For("IPersons")
|
||||
// .Filter("Name eq \'Маударбеков Азат Муратбекович\'")
|
||||
// .FindEntriesAsync();
|
||||
// foreach (dynamic person in peoples)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// long Id = person["Id"];
|
||||
// await _client
|
||||
// .For("IPersons")
|
||||
// .Key(Id)
|
||||
// .DeleteEntryAsync();
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
[HttpPost("SendContract")]
|
||||
public async Task SendContractTo1C(Contract contract)
|
||||
public async Task SendContractTo1C([FromBody]Contract contract)
|
||||
{
|
||||
JsonSerializerOptions options = new()
|
||||
{
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace _1CDataBus.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
namespace _1CDataBus.Structure
|
||||
using System.Globalization;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace _1CDataBus.Structure
|
||||
{
|
||||
public class Contract
|
||||
{
|
||||
@ -9,18 +12,49 @@
|
||||
{ 3, "Прочее" }
|
||||
};
|
||||
|
||||
private List<string> _orderDealKinds = ["Приобретение ТМЦ", "Приобретение топлива"];
|
||||
|
||||
public Contract(dynamic contract)
|
||||
{
|
||||
Name = contract["Name"];
|
||||
//Name = contract["Name"];
|
||||
BusinessUnit = contract["BusinessUnit"]["ExternalId"];
|
||||
BusinessUnitBIN = contract["BusinessUnit"]["BINArmadoc"];
|
||||
Counterparty = contract["Counterparty"]["ExternalId"];
|
||||
CounterpartyBIN = contract["Counterparty"]["BINArmadoc"];
|
||||
CreateDate = contract["Created"].Date;
|
||||
Number = contract["RegistrationNumber"];
|
||||
Date = contract["ContractDateSungero"].Date;
|
||||
Currency = contract["Currency"]["AlphaCode"];
|
||||
QDocID = contract["Id"];
|
||||
Date = contract["ContractDateSungero"].Date.ToString("yyyy-MM-dd");
|
||||
Currency = contract["Currency"] == null ? "KZT" : contract["Currency"]["AlphaCode"];
|
||||
QDocID = contract["Id"].ToString();
|
||||
Name = GetName();
|
||||
|
||||
string dealKind = contract["DealKindSungero"]["Name"];
|
||||
if (dealKind != null && _orderDealKinds.Contains(dealKind)) Orders = true;
|
||||
}
|
||||
|
||||
private string GetName()
|
||||
{
|
||||
var culture = CultureInfo.InvariantCulture;
|
||||
var result = "Договор";
|
||||
|
||||
if (!string.IsNullOrEmpty(this.Number)) result += $" {this.Number}";
|
||||
if (!string.IsNullOrEmpty(this.Date)) result += $" от {DateTime.ParseExact(this.Date, "yyyy-MM-dd", culture).ToString("dd.MM.yyyy")}";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[JsonConstructor]
|
||||
public Contract(string name, string businessUnit, string businessUnitBIN, string counterparty, string counterpartyBIN,
|
||||
string number, DateTime date, string currency, string qDocID)
|
||||
{
|
||||
Name = name;
|
||||
BusinessUnit = businessUnit;
|
||||
BusinessUnitBIN = businessUnitBIN;
|
||||
Counterparty = counterparty;
|
||||
CounterpartyBIN = counterpartyBIN;
|
||||
Number = number;
|
||||
Date = date.ToString("yyyy-MM-dd");
|
||||
Currency = currency;
|
||||
QDocID = qDocID;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
@ -28,12 +62,11 @@
|
||||
public string BusinessUnitBIN { get; set; }
|
||||
public string Counterparty { get; set; }
|
||||
public string CounterpartyBIN { get; set; }
|
||||
public DateTimeOffset CreateDate { get; set; } = DateTimeOffset.Now;
|
||||
public string Number { get; set; }
|
||||
public DateTimeOffset Date { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string ContractKind { get; set; } = "Поставщик";
|
||||
public string Currency { get; set; }
|
||||
public bool Orders { get; set; } = false;
|
||||
public long QDocID { get; set; }
|
||||
public string QDocID { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
namespace _1CDataBus
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
@ -12,12 +12,12 @@
|
||||
"Password": "Z!1;Q5#GE4v",
|
||||
"VirtualHost": "erp"
|
||||
},
|
||||
"QDocSettings": {
|
||||
"QDocTestSettings": {
|
||||
"Url": "https://qdoc.solidcore-resources.com/Integration/odata/",
|
||||
"Login": "Administrator",
|
||||
"Password": "MQVuEw9avO"
|
||||
},
|
||||
"QDocTestSettings": {
|
||||
"QDocSettings": {
|
||||
"Url": "https://astsrvqtest.solidcore-resources.com/Integration/odata/",
|
||||
"Login": "Administrator",
|
||||
"Password": "D3cTXol8Se"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user