@@ -159,11 +159,12 @@ export class CashierComponent implements OnInit, AfterViewInit {
159159 constructor ( ...args : unknown [ ] ) ;
160160
161161 constructor ( ) {
162- // Subscribe to scale readings
162+ // Subscribe to saved scale weight
163163 effect ( ( ) => {
164- this . scaleService . currentWeight $. subscribe ( ( reading ) => {
164+ this . scaleService . savedWeight $. subscribe ( ( reading ) => {
165165 this . currentScaleReading . set ( reading ) ;
166- if ( this . useScaleWeight ( ) && reading && reading . stable ) {
166+ // Auto-populate weight when saved weight is available
167+ if ( reading && reading . weight > 0 ) {
167168 this . looseProductWeight . set ( reading . weight . toFixed ( 3 ) ) ;
168169 }
169170 } ) ;
@@ -719,30 +720,9 @@ export class CashierComponent implements OnInit, AfterViewInit {
719720 this . useScaleWeight . set ( false ) ;
720721 }
721722
722- async connectToScale ( ) : Promise < void > {
723- const connected = await this . scaleService . connectScale ( ) ;
724- this . scaleConnected . set ( connected ) ;
725- if ( connected ) {
726- this . useScaleWeight . set ( true ) ;
727- this . toastService . show ( "Scale connected successfully!" , "success" ) ;
728- } else {
729- this . toastService . show (
730- "Failed to connect to scale. Make sure the scale is connected via USB." ,
731- "error"
732- ) ;
733- }
734- }
735-
736- async disconnectScale ( ) : Promise < void > {
737- await this . scaleService . disconnectScale ( ) ;
738- this . scaleConnected . set ( false ) ;
739- this . useScaleWeight . set ( false ) ;
740- this . currentScaleReading . set ( null ) ;
741- }
742-
743723 toggleUseScaleWeight ( ) : void {
744724 if ( ! this . scaleConnected ( ) ) {
745- this . toastService . show ( "Please connect to a scale first." , "info" ) ;
725+ this . toastService . show ( "Connect scale from Settings first." , "info" ) ;
746726 return ;
747727 }
748728 this . useScaleWeight . update ( ( v ) => ! v ) ;
@@ -969,14 +949,19 @@ export class CashierComponent implements OnInit, AfterViewInit {
969949
970950 this . toastService . show ( message , "success" ) ;
971951
972- // Generate and print receipt using the saved template
973- const mode = localStorage . getItem ( "printer.mode" ) || "plain" ;
974- const isPlainText = mode !== "styled" ;
975- this . receiptGeneratorService
976- . printSaleReceipt ( createdSale , { plainText : isPlainText } )
977- . catch ( ( err ) => {
978- console . error ( "Error printing receipt:" , err ) ;
979- } ) ;
952+ // Generate and print receipt using the saved template (if enabled)
953+ const register = this . currentRegister ( ) ;
954+ const shouldPrint = register ?. printReceiptsEnabled !== false ;
955+
956+ if ( shouldPrint ) {
957+ const mode = localStorage . getItem ( "printer.mode" ) || "plain" ;
958+ const isPlainText = mode !== "styled" ;
959+ this . receiptGeneratorService
960+ . printSaleReceipt ( createdSale , { plainText : isPlainText } )
961+ . catch ( ( err ) => {
962+ console . error ( "Error printing receipt:" , err ) ;
963+ } ) ;
964+ }
980965
981966 // Mark cart as completed after successful sale
982967 if ( this . activeCartId ( ) ) {
0 commit comments