feat: implement invoice payments component and integrate with supplier invoices
This commit is contained in:
@@ -63,8 +63,6 @@ export class CardexFiltersComponent {
|
||||
this.store.setDefaultInventory(inventory);
|
||||
}
|
||||
setDefaultProduct(product: IProductResponse) {
|
||||
console.log('setDefaultProduct');
|
||||
|
||||
this.store.setDefaultProduct(product);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface CardexState extends PaginatedState<ICardexResponse> {
|
||||
selectedProduct: Maybe<ICardexProductSummary>;
|
||||
variant: 'inventory' | 'product' | 'general';
|
||||
canChangeVariant: boolean;
|
||||
cardexTitle: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -63,6 +64,7 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
selectedProduct: null,
|
||||
variant: 'general',
|
||||
canChangeVariant: true,
|
||||
cardexTitle: 'کاردکس',
|
||||
});
|
||||
this.initial();
|
||||
}
|
||||
@@ -70,18 +72,7 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
readonly filters = computed(() => this._state().filters);
|
||||
readonly variant = computed(() => this._state().variant);
|
||||
readonly canChangeVariant = computed(() => this._state().canChangeVariant);
|
||||
readonly cardexTitle = computed(() => {
|
||||
switch (this._state().variant) {
|
||||
case 'product':
|
||||
return `کاردکس کالای ${this._state().selectedProduct?.name}`;
|
||||
case 'inventory':
|
||||
return `کاردکس انبار ${this._state().selectedInventory?.name}`;
|
||||
default:
|
||||
return `کاردکس ${this._state().selectedProduct ? 'کالای ' + this._state().selectedProduct?.name : ''} ${
|
||||
this._state().selectedInventory ? 'در انبار ' + this._state().selectedInventory?.name : ''
|
||||
}`;
|
||||
}
|
||||
});
|
||||
readonly cardexTitle = computed(() => this._state().cardexTitle);
|
||||
|
||||
/**
|
||||
* Reset state to initial values
|
||||
@@ -109,6 +100,7 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
selectedProduct: null,
|
||||
variant: 'general',
|
||||
canChangeVariant: this.state().canChangeVariant,
|
||||
cardexTitle: 'کاردکس',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,8 +147,6 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
updateFilter(filters: ICardexRequestPayload) {
|
||||
this.updateVariant();
|
||||
|
||||
console.log('filters');
|
||||
console.log(filters);
|
||||
const cleanedFilters = this.validateFilters() || {};
|
||||
|
||||
this.router
|
||||
@@ -169,6 +159,7 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
console.log(err);
|
||||
});
|
||||
this.patchState({ filters });
|
||||
this.updateCardexTitle();
|
||||
}
|
||||
|
||||
setProduct(product: Maybe<ICardexProductSummary>) {
|
||||
@@ -184,10 +175,12 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
|
||||
setDefaultInventory(inventory: ICardexInventorySummary) {
|
||||
this.patchState({ selectedInventory: inventory });
|
||||
this.updateCardexTitle();
|
||||
}
|
||||
|
||||
setDefaultProduct(product: ICardexProductSummary) {
|
||||
this.patchState({ selectedProduct: product });
|
||||
this.updateCardexTitle();
|
||||
}
|
||||
|
||||
private updateVariant() {
|
||||
@@ -201,7 +194,27 @@ export class CardexStore extends PaginatedStore<ICardexResponse, CardexState> {
|
||||
} else if (productIsSelected) {
|
||||
variant = 'product';
|
||||
}
|
||||
this.updateCardexTitle();
|
||||
|
||||
this.patchState({ variant });
|
||||
}
|
||||
|
||||
updateCardexTitle() {
|
||||
let title = '';
|
||||
switch (this._state().variant) {
|
||||
case 'product':
|
||||
title = `کاردکس کالای ${this._state().selectedProduct?.name}`;
|
||||
break;
|
||||
case 'inventory':
|
||||
title = `کاردکس انبار ${this._state().selectedInventory?.name}`;
|
||||
break;
|
||||
default:
|
||||
title = `کاردکس ${this._state().selectedProduct ? 'کالای ' + this._state().selectedProduct?.name : ''} ${
|
||||
this._state().selectedInventory ? 'در انبار ' + this._state().selectedInventory?.name : ''
|
||||
}`;
|
||||
break;
|
||||
}
|
||||
|
||||
this.patchState({ cardexTitle: title });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user