Compare commits

...

2 Commits

Author SHA1 Message Date
a079bb9100 fix : transaction summary html 2025-08-08 11:48:04 +05:30
b1590067cb fix : added transaction summary details 2025-08-08 11:47:18 +05:30
6 changed files with 212 additions and 35 deletions

View File

@ -20,25 +20,30 @@
<col style="width: 65%" />
</colgroup>
<tbody>
<tr>
<td class="custom-cell pure-white">Sales</td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white">{{ totalClicks }}</td>
<td class="custom-cell pure-white">{{ salesTotal }}</td>
<!-- <td class="custom-cell pure-white">
{{ showSalesTotal ? salesTotal : '' }}
</td> -->
</tr>
<tr>
<td class="custom-cell pure-white">Cancel</td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white">0</td>
<td class="custom-cell pure-white">0</td>
</tr>
<tr>
<td class="custom-cell pure-white">Payout</td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white">0</td>
<td class="custom-cell pure-white">0</td>
</tr>
<tr>
<td class="custom-cell pure-white">Receive</td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white"></td>
<td class="custom-cell pure-white">{{ totalClicks }}</td>
<td class="custom-cell pure-white">{{ salesTotal }}</td>
</tr>
</tbody>
</table>

View File

@ -18,6 +18,9 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
filledRows: SelectionData[] = [];
currentRow: SelectionData = { label: '', numbers: [], value: 0, total: 0 };
grandTotal: number = 0;
salesTotal: number = 0;
receiveTotal: number = 0;
totalClicks: number = 0;
showConfirmButton: boolean = false;
lastTicket: any = null;
showRepeatTicket: boolean = false;
@ -63,10 +66,31 @@ export class MiddleSectionComponent implements OnInit, OnDestroy {
this.filledRows = [...rows, ...emptyRows].slice(0, 5);
this.calculateTotal();
}
showSalesTotal: boolean = false;
calculateTotal() {
this.grandTotal = this.filledRows.reduce((sum, row) => sum + (row.total || 0), 0);
let storedTotal = 0;
try {
const storedTickets = JSON.parse(localStorage.getItem('localTickets') || '[]');
if (Array.isArray(storedTickets)) {
storedTotal = storedTickets
.filter(ticket => ticket.type === 'ticket')
.reduce((sum: number, ticket: any) => sum + (ticket.totalAmount || 0), 0);
}
} catch (e) {
console.error('❌ Failed to parse localTickets from localStorage:', e);
}
this.salesTotal = this.grandTotal + storedTotal;
this.receiveTotal = this.salesTotal;
this.totalClicks = Number(localStorage.getItem('printClickCount') || '0');
// 👇 Toggle visibility based on localStorage flag
this.showSalesTotal = localStorage.getItem('hasPrinted') === 'true';
}
repeat() {
try {

View File

@ -68,6 +68,7 @@ export class SidebarComponent {
//--------------------Printer Logic added here ----------------------------------------------
//---------------------------------Print Payout Ticket --------------------------------------------------------
printPayoutTicket() {
@ -129,11 +130,65 @@ printPayoutTicket() {
this.depositAmount = '';
}
//----------------------------Print Deposit ticket -------------------------------------------------------
printDeposit() {
alert(`Deposit: ₹${this.depositAmount}`);
const userName = localStorage.getItem('userName') || 'Unknown';
const receiptText = `
==============================
💰 DEPOSIT RECEIPT
==============================
Operator ID : ${this.depositOperatorId}
Shroff ID : ${this.depositShroffId}
Amount : ${this.depositAmount}
Printed By : ${userName}
Date : ${new Date().toLocaleString()}
==============================
🧾 Denomination Voucher
1000 x _____________ = _____________
500 x _____________ = _____________
100 x _____________ = _____________
50 x _____________ = _____________
20 x _____________ = _____________
10 x _____________ = _____________
5 x _____________ = _____________
==============================
`;
// ✅ Send to print server
const payload = {
type: 'deposit',
printedBy: userName,
operatorId: this.depositOperatorId,
shroffId: this.depositShroffId,
amount: this.depositAmount,
content: receiptText // 🧾 Include formatted text
};
fetch('http://localhost:9100/print', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) throw new Error(`Printer error: ${response.status}`);
return response.text();
})
.then(result => {
console.log("✅ Deposit print successful:", result);
})
.catch(error => {
console.error("❌ Deposit print failed:", error);
});
this.closeDepositPopup();
}
//-----------------------------------------------------------------------------------------------------------------
openWithdrawPopup() {
this.withdrawClick.emit();
this.showWithdraw = true;
@ -146,12 +201,69 @@ printPayoutTicket() {
this.withdrawAmount = '';
}
// printWithdraw() {
// alert(`Withdraw: ₹${this.withdrawAmount}`);
// this.closeWithdrawPopup();
// }
printWithdraw() {
alert(`Withdraw: ₹${this.withdrawAmount}`);
const userName = localStorage.getItem('userName') || 'Unknown';
const receiptText = `
==============================
💸 WITHDRAW RECEIPT
==============================
Operator ID : ${this.withdrawOperatorId}
Shroff ID : ${this.withdrawShroffId}
Amount : ${this.withdrawAmount}
Printed By : ${userName}
Date : ${new Date().toLocaleString()}
==============================
🧾 Denomination Voucher
1000 x _____________ = _____________
500 x _____________ = _____________
100 x _____________ = _____________
50 x _____________ = _____________
20 x _____________ = _____________
10 x _____________ = _____________
5 x _____________ = _____________
==============================
`;
const payload = {
type: 'withdraw',
printedBy: userName,
operatorId: this.withdrawOperatorId,
shroffId: this.withdrawShroffId,
amount: this.withdrawAmount,
content: receiptText
};
fetch('http://localhost:9100/print', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) throw new Error(`Printer error: ${response.status}`);
return response.text();
})
.then(result => {
console.log("✅ Withdraw print successful:", result);
})
.catch(error => {
console.error("❌ Withdraw print failed:", error);
});
this.closeWithdrawPopup();
}
raceCardData: any = null; // ✅ Hold fetched data

View File

@ -6,7 +6,7 @@
<!-- Left Group: CALC, ERASE, BOX, FIELD -->
<div class="d-flex flex-wrap justify-content-center gap-2 first">
<button class="btn btn-dark one" (click)="openCalculator()">CALC</button>
<button class="btn btn-dark two" (click)="erase()">ERASE</button>
<button class="btn btn-dark two" (click)="eraseAndReload()">ERASE</button>
<button
class="btn btn-secondary three"
(click)="toggleBoxMode()"
@ -28,7 +28,7 @@
</button>
<button class="btn btn-dark" (click)="copyNumbers()">COPY</button>
<button class="btn btn-danger btn-bkp" *ngIf="showBackspace" (click)="removeLastNumber()">BKP</button>
<button class="btn btn-dark">CLEAR</button>
<button class="btn btn-dark" (click)="clearLocalTickets()">CLEAR</button>
<button class="btn btn-info pool-replace-btn" (click)="openPoolReplaceModal()">PR</button>
</div>
</div>

View File

@ -795,9 +795,21 @@ getHorseNumbersForRaceIdx(raceIdx: number): number[] {
return [];
}
}
clearLocalTickets() {
localStorage.removeItem('localTickets');
console.log('🧹 localTickets cleared from localStorage');
// Clear the print count
localStorage.removeItem('printClickCount');
console.log('🧼 printClickCount cleared from localStorage');
// Reset via shared state
this.sharedStateService.setSalesTotal(0);
this.sharedStateService.setReceiveTotal(0);
window.location.reload();
// Optionally clear print clicks
// localStorage.removeItem('printClickCount');
}
//-------------------PRINT LOGIC----------------------------------------
@ -817,6 +829,12 @@ printTicket() {
let allRows = [...selections];
// ✅ Just count clicks — update click count in localStorage
let clickCount = Number(localStorage.getItem('printClickCount') || '0');
clickCount += 1;
localStorage.setItem('printClickCount', clickCount.toString());
// ✅ Calculate total if currentRow is valid and not already finalized
if (currentRow.label && currentRow.numbers.length > 0 && currentRow.value > 0) {
if (!currentRow.total) {
@ -987,24 +1005,24 @@ const winLabels = allRows.map(row => {
// ---------------------sending data to backend ---------------------------------
// try {
// const existingTicketsStr = localStorage.getItem('localTickets');
// const existingTickets = existingTicketsStr ? JSON.parse(existingTicketsStr) : [];
// existingTickets.push(payload);
// localStorage.setItem('localTickets', JSON.stringify(existingTickets));
// console.log('📦 [DEBUG] Ticket saved locally to localStorage.');
// } catch (error) {
// console.error('❌ Failed to store ticket locally:', error);
// }
try {
localStorage.setItem('localTickets', JSON.stringify([payload]));
console.log('📦 [DEBUG] Latest ticket stored in localStorage (previous cleared).');
const existingTicketsStr = localStorage.getItem('localTickets');
const existingTickets = existingTicketsStr ? JSON.parse(existingTicketsStr) : [];
existingTickets.push(payload);
localStorage.setItem('localTickets', JSON.stringify(existingTickets));
console.log('📦 [DEBUG] Ticket saved locally to localStorage.');
} catch (error) {
console.error('❌ Failed to store ticket locally:', error);
}
// try {
// localStorage.setItem('localTickets', JSON.stringify([payload]));
// console.log('📦 [DEBUG] Latest ticket stored in localStorage (previous cleared).');
// } catch (error) {
// console.error('❌ Failed to store ticket locally:', error);
// }
fetch('http://192.168.1.12:8083/api/tickets', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@ -1037,14 +1055,15 @@ try {
}
//----------------------------------PRINT ENDS HERE ------------------------------------------------------
erase() {
this.selectionService.clearSelections();
this.resetSelections();
}
eraseAndReload() {
this.erase();
window.location.reload();
}
resetSelections() {
this.selectedLabel = null;

View File

@ -52,4 +52,21 @@ export class SharedStateService {
getSelectedRace(): number {
return this.selectedRaceSubject.value;
}
private salesTotalSubject = new BehaviorSubject<number>(0);
salesTotal$ = this.salesTotalSubject.asObservable();
private receiveTotalSubject = new BehaviorSubject<number>(0);
receiveTotal$ = this.receiveTotalSubject.asObservable();
// Methods to update
setSalesTotal(total: number) {
this.salesTotalSubject.next(total);
}
setReceiveTotal(total: number) {
this.receiveTotalSubject.next(total);
}
}