Correct language in invoice and receipt

This commit is contained in:
Rene Vergara 2023-06-20 14:10:44 -05:00
parent 2cd0ee76c0
commit 92865a6ee3
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 11 additions and 11 deletions

View file

@ -22,6 +22,7 @@ export class LanguageService {
private loginURL = ConfigData.Be_URL + 'getloginlang';
private mainURL = ConfigData.Be_URL + 'getmainlang';
private scanURL = ConfigData.Be_URL + 'getscanlang';
private invoiceURL = ConfigData.Be_URL + 'getinvoicelang';
public zgoLanguage: string = '';
@ -58,6 +59,8 @@ export class LanguageService {
return this.http.get<LanguageData>(this.mainURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else if (viewName === 'scan') {
return this.http.get<LanguageData>(this.scanURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else if (viewName === 'invoice') {
return this.http.get<LanguageData>(this.invoiceURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else {
return this.http.get<LanguageData>(this.baseURL +
'/?lang=' + this.zgoLanguage +

View file

@ -14,7 +14,8 @@ var Buffer = require('buffer/').Buffer;
})
export class ReceiptService {
beUrl = ConfigData.Be_URL;
private dataStore: {order: Order, owner: Owner } = {
private dataStore: {order: Order, owner: Owner, name: string } = {
name: '',
owner: {
_id: '',
name: '',
@ -58,34 +59,30 @@ export class ReceiptService {
public readonly orderUpdate: Observable<Order> = this._orderUpdated.asObservable();
public _nameUpdated: BehaviorSubject<string> = new BehaviorSubject(this.dataStore.owner.name);
public readonly nameUpdate: Observable<string>= this._nameUpdated.asObservable();
public readonly ownerUpdate;
//public readonly ownerUpdate;
private reqHeaders: HttpHeaders;
private session: null|string;
private params: HttpParams;
constructor(
private http: HttpClient,
public userService: UserService
) {
this.session = localStorage.getItem('s4z_token');
//this.session = localStorage.getItem('s4z_token');
this.params = new HttpParams();
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.ownerUpdate = userService.ownerUpdate;
//this.ownerUpdate = userService.ownerUpdate;
}
getOrderById(id:string, token: string) {
let obs = this.http.get<{message: string, order: any}>(this.beUrl+'order/'+id, { headers:this.reqHeaders, params: this.params.append("token", token), observe: 'response'});
let obs = this.http.get<{message: string, order: any, shop: string}>(this.beUrl+'order/'+id, { headers:this.reqHeaders, params: this.params.append("token", token), observe: 'response'});
obs.subscribe((OrderDataResponse) => {
if (OrderDataResponse.status == 200) {
this.dataStore.order = OrderDataResponse.body!.order;
this.dataStore.name = OrderDataResponse.body!.shop;
this._orderUpdated.next(Object.assign({}, this.dataStore).order);
this.userService.getOwner();
this.ownerUpdate.subscribe((owner) => {
this.dataStore.owner = owner;
this._nameUpdated.next(Object.assign({}, this.dataStore).owner.name);
});
this._nameUpdated.next(Object.assign({}, this.dataStore).name);
} else {
this._orderUpdated.next(Object.assign({}, this.dataStore).order);
console.log('No order found');