|
|
|
|
@@ -604,6 +604,8 @@ export class CartSalesComponent
|
|
|
|
|
this.stores.find((s) => s.id === this.authService.getStore())
|
|
|
|
|
);
|
|
|
|
|
localStorage.setItem('invoiceStore', saveStoreInvoice);
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.formPayment.patchValue({
|
|
|
|
|
invoiceStore: JSON.parse(saveStoreInvoice),
|
|
|
|
|
@@ -750,6 +752,7 @@ export class CartSalesComponent
|
|
|
|
|
if (localStorage.getItem('paymentPlan') === 'undefined') {
|
|
|
|
|
localStorage.setItem('paymentPlan', JSON.stringify(paymentPlan));
|
|
|
|
|
this.selectPaymentPlan = paymentPlan;
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
this.confirmChangePaymentPlan(true);
|
|
|
|
|
} else {
|
|
|
|
|
this.selectPaymentPlan = paymentPlan;
|
|
|
|
|
@@ -767,6 +770,7 @@ export class CartSalesComponent
|
|
|
|
|
'paymentPlan',
|
|
|
|
|
JSON.stringify(this.selectPaymentPlan)
|
|
|
|
|
);
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
const billing = JSON.parse(localStorage.getItem('billing')) as Billing;
|
|
|
|
|
this.idPaymentPlan = this.selectPaymentPlan.codplpag;
|
|
|
|
|
this.subscriptionUpdatePayment = this.shoppingService
|
|
|
|
|
@@ -807,6 +811,7 @@ export class CartSalesComponent
|
|
|
|
|
tap((planos) => console.log(planos))
|
|
|
|
|
)
|
|
|
|
|
.subscribe();
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setPartner(partner: any) {
|
|
|
|
|
@@ -815,6 +820,7 @@ export class CartSalesComponent
|
|
|
|
|
|
|
|
|
|
setInvoiceStore(invoiceStore: any) {
|
|
|
|
|
localStorage.setItem('invoiceStore', JSON.stringify(invoiceStore));
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isInvoiceStore9Or10() {
|
|
|
|
|
@@ -930,14 +936,14 @@ export class CartSalesComponent
|
|
|
|
|
const customer = JSON.parse(localStorage.getItem('customer')) as Customer;
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('customer') != undefined) {
|
|
|
|
|
if (customer.place.id == 19) {
|
|
|
|
|
this.titleInformation = 'Pedido de venda';
|
|
|
|
|
this.messageInformation = 'ATENÇÃO! Cliente com praça do E-COMMERCE!';
|
|
|
|
|
this.informationDescription =
|
|
|
|
|
'Altere a praça do cliente pela opção NOVO CLIENTE para continuar.';
|
|
|
|
|
this.showInformation = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if (customer.place.id == 19) {
|
|
|
|
|
// this.titleInformation = 'Pedido de venda';
|
|
|
|
|
// this.messageInformation = 'ATENÇÃO! Cliente com praça do E-COMMERCE!';
|
|
|
|
|
// this.informationDescription =
|
|
|
|
|
// 'Altere a praça do cliente pela opção NOVO CLIENTE para continuar.';
|
|
|
|
|
// this.showInformation = true;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
if (
|
|
|
|
|
customer.place.name == 'INATIVO' ||
|
|
|
|
|
customer.place.name == 'INATIVA'
|
|
|
|
|
@@ -1000,6 +1006,7 @@ export class CartSalesComponent
|
|
|
|
|
}
|
|
|
|
|
this.updateFormCustomer(result);
|
|
|
|
|
localStorage.setItem('customer', JSON.stringify(result));
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
this.updateTaxDelivery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1579,20 +1586,29 @@ export class CartSalesComponent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public updateCart(
|
|
|
|
|
cartId: string,
|
|
|
|
|
customerId: number,
|
|
|
|
|
addressId: number,
|
|
|
|
|
saleStoreId: string,
|
|
|
|
|
paymentPlanId: number,
|
|
|
|
|
billingId: string
|
|
|
|
|
cartId: string
|
|
|
|
|
) {
|
|
|
|
|
console.log('Atualizando carrinho: ' + cartId);
|
|
|
|
|
this.shoppingService.getShopping(cartId).subscribe((shopping) => {
|
|
|
|
|
if (shopping) {
|
|
|
|
|
shopping.codcli = customerId;
|
|
|
|
|
shopping.codendentcli = addressId;
|
|
|
|
|
shopping.saleStore = saleStoreId;
|
|
|
|
|
shopping.codplpag = paymentPlanId;
|
|
|
|
|
shopping.codcob = billingId;
|
|
|
|
|
console.log('Carrinho encontrado: ' + JSON.stringify(shopping));
|
|
|
|
|
const invoiceStore = JSON.parse(
|
|
|
|
|
localStorage.getItem('invoiceStore')
|
|
|
|
|
) as StoreERP;
|
|
|
|
|
const customer = JSON.parse(localStorage.getItem('customer')) as Customer;
|
|
|
|
|
const address = JSON.parse(
|
|
|
|
|
localStorage.getItem('address')
|
|
|
|
|
) as CustomerAddress;
|
|
|
|
|
const paymentPlan = JSON.parse(
|
|
|
|
|
localStorage.getItem('paymentPlan')
|
|
|
|
|
) as PaymentPlan;
|
|
|
|
|
const billing = JSON.parse(localStorage.getItem('billing')) as Billing;
|
|
|
|
|
|
|
|
|
|
shopping.codcli = customer ? customer.customerId : 0;
|
|
|
|
|
shopping.codendentcli = address ? address.idAddress : 0;
|
|
|
|
|
shopping.saleStore = invoiceStore ? invoiceStore.id : this.authService.getStore();
|
|
|
|
|
shopping.codplpag = paymentPlan ? paymentPlan.codplpag : 0;
|
|
|
|
|
shopping.codcob = billing ? billing.codcob : '';
|
|
|
|
|
|
|
|
|
|
this.shoppingService.updateShopping(shopping).subscribe(
|
|
|
|
|
(response) => {
|
|
|
|
|
@@ -1630,6 +1646,7 @@ export class CartSalesComponent
|
|
|
|
|
this.showSelectAddress = false;
|
|
|
|
|
if (result != null) {
|
|
|
|
|
localStorage.setItem('address', JSON.stringify(result));
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
this.updateFormAddress(result);
|
|
|
|
|
this.updateTaxDelivery();
|
|
|
|
|
}
|
|
|
|
|
@@ -2331,6 +2348,7 @@ export class CartSalesComponent
|
|
|
|
|
if (action === 'Sim') {
|
|
|
|
|
if (this.customer !== undefined && this.customer.customerId !== 1) {
|
|
|
|
|
localStorage.setItem('customer', JSON.stringify(this.customer));
|
|
|
|
|
this.updateCart(this.shoppingService.getCart());
|
|
|
|
|
this.updateFormCustomer(this.customer);
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
|