2024-09-30 15:19:20 -05:00
|
|
|
import { StartSaleOutputInterface } from "@interfaces/OutputInterfaces/Sale/StartSaleOutputInterface";
|
|
|
|
|
import { StartSaleResponseInterface } from "@interfaces/ResponseInterfaces/Sale/StartSaleResponseInterface";
|
|
|
|
|
import { BASE_URL_SALE } from "@package/config/ApiPath";
|
|
|
|
|
import { FetchData } from "@package/config/FetchData";
|
|
|
|
|
import { ReturnService } from "@package/config/ReturnService"
|
|
|
|
|
import { BASE_URL_LANGUAGE } from "@utils/Constants"
|
|
|
|
|
import i18n from "@utils/language/i18n";
|
|
|
|
|
import { getKeyApi } from "@utils/Utilities"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function StartSale(ae_object: StartSaleOutputInterface) {
|
|
|
|
|
const token = getKeyApi()
|
|
|
|
|
if (token === '') {
|
|
|
|
|
return new ReturnService('', false, i18n.t('errorTokenAPI'), 102)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const options: RequestInit = {
|
|
|
|
|
method: 'post',
|
|
|
|
|
mode: 'cors',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
Authorization: 'Bearer ' + token,
|
|
|
|
|
lng: BASE_URL_LANGUAGE
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
storeNumber: ae_object.storeNumber ?? '',
|
|
|
|
|
idSubsidiary: ae_object.idSubsidiary ?? 0,
|
|
|
|
|
idClient: ae_object.idClient ?? '',
|
|
|
|
|
clientDni: ae_object.clientDni ?? '',
|
|
|
|
|
idType: ae_object.idType ?? '',
|
|
|
|
|
idGroup: ae_object.idGroup ?? '',
|
|
|
|
|
invoiceName: ae_object.invoiceName ?? '',
|
|
|
|
|
invoiceTypeNit: ae_object.invoiceTypeNit ?? '',
|
|
|
|
|
invoiceNit: ae_object.invoiceNit ?? '',
|
|
|
|
|
invoiceDirection: ae_object.invoiceDirection ?? '',
|
|
|
|
|
invoiceCellPhone: ae_object.invoiceCellPhone ?? '',
|
|
|
|
|
invoiceEmail: ae_object.invoiceEmail ?? '',
|
|
|
|
|
idUser: ae_object.idUser ?? '',
|
|
|
|
|
localDate: ae_object.localDate ?? '',
|
|
|
|
|
pos: ae_object.pos ?? '',
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-01 13:45:34 -05:00
|
|
|
let data : StartSaleResponseInterface = await FetchData(BASE_URL_SALE, 'startSale', options)
|
2024-09-30 15:19:20 -05:00
|
|
|
|
|
|
|
|
if (data.correct) {
|
|
|
|
|
return data.object
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default StartSale
|