@@ -7,7 +7,7 @@ import { AuthManager } from './auth/authentication.js';
77import { FirebaseService } from './firebase/firestore-service.js' ;
88import { ItemsManager } from './modules/items.js' ;
99import { PrinterService , printerManager } from './services/printer.js' ;
10- import { BillingManager } from './modules/billing.js' ;
10+ import { BillingManager , PurchaseManager , RetailSaleManager } from './modules/billing.js' ;
1111import { StockManager } from './modules/stock.js' ;
1212import { WholesaleSalesManager } from './modules/wholesale-sales.js' ;
1313import { HistoryManager } from './modules/history.js' ;
@@ -129,6 +129,9 @@ async function loadUserDataAndInitialize() {
129129 // Calculate stock
130130 AppState . stock = await FirebaseService . calculateStock ( ) ;
131131
132+ // Initialize billing manager (connects purchase and retail-sale modules)
133+ BillingManager . init ( ) ;
134+
132135 // Set up real-time listeners
133136 FirebaseService . setupRealtimeListeners ( ) ;
134137
@@ -365,6 +368,49 @@ window.app = {
365368 checkAutoSave : ( ) => BillingManager . checkAutoSave ( )
366369 } ,
367370
371+ // Purchase (direct access to PurchaseManager)
372+ purchase : {
373+ addWeight : ( autoAdd ) => PurchaseManager . addWeight ( autoAdd ) ,
374+ renderWeights : ( ) => PurchaseManager . renderWeights ( ) ,
375+ removeWeight : ( idx ) => PurchaseManager . removeWeight ( idx ) ,
376+ clearWeights : ( ) => PurchaseManager . clearWeights ( ) ,
377+ addToBill : ( autoAdd ) => PurchaseManager . addToBill ( autoAdd ) ,
378+ renderBill : ( ) => PurchaseManager . renderBill ( ) ,
379+ deleteBillItem : ( idx ) => PurchaseManager . deleteBillItem ( idx ) ,
380+ editBillItem : ( idx ) => PurchaseManager . editBillItem ( idx ) ,
381+ updateTotals : ( heavy ) => PurchaseManager . updateTotals ( heavy ) ,
382+ updatePaymentTotal : ( ) => PurchaseManager . updatePaymentTotal ( ) ,
383+ fillPayableAmount : ( type ) => PurchaseManager . fillPayableAmount ( type ) ,
384+ saveBillToHistory : ( ) => PurchaseManager . saveBillToHistory ( ) ,
385+ shareWhatsApp : ( ) => PurchaseManager . shareWhatsApp ( ) ,
386+ getBillItems : ( ) => PurchaseManager . getBillItems ( ) ,
387+ getWeights : ( ) => PurchaseManager . getWeights ( ) ,
388+ clearBill : ( ) => PurchaseManager . clearBill ( )
389+ } ,
390+
391+ // Retail Sale (direct access to RetailSaleManager)
392+ retailSale : {
393+ addSaleWeight : ( autoAdd ) => RetailSaleManager . addSaleWeight ( autoAdd ) ,
394+ renderSaleWeights : ( ) => RetailSaleManager . renderSaleWeights ( ) ,
395+ removeSaleWeight : ( idx ) => RetailSaleManager . removeSaleWeight ( idx ) ,
396+ clearSaleWeights : ( ) => RetailSaleManager . clearSaleWeights ( ) ,
397+ addToSalesBill : ( autoAdd ) => RetailSaleManager . addToSalesBill ( autoAdd ) ,
398+ renderSalesBill : ( ) => RetailSaleManager . renderSalesBill ( ) ,
399+ removeSaleItem : ( idx ) => RetailSaleManager . removeSaleItem ( idx ) ,
400+ editSaleItem : ( idx ) => RetailSaleManager . editSaleItem ( idx ) ,
401+ updateSaleTotals : ( ) => RetailSaleManager . updateSaleTotals ( ) ,
402+ updateSaleRunningTotal : ( ) => RetailSaleManager . updateSaleRunningTotal ( ) ,
403+ updateSalePaymentTotal : ( ) => RetailSaleManager . updateSalePaymentTotal ( ) ,
404+ fillReceivableAmount : ( type ) => RetailSaleManager . fillReceivableAmount ( type ) ,
405+ completeSale : ( ) => RetailSaleManager . completeSale ( ) ,
406+ shareSaleWhatsApp : ( ) => RetailSaleManager . shareSaleWhatsApp ( ) ,
407+ printSale : ( ) => RetailSaleManager . printSale ( ) ,
408+ pickSaleContact : ( ) => RetailSaleManager . pickSaleContact ( ) ,
409+ getSaleItems : ( ) => RetailSaleManager . getSaleItems ( ) ,
410+ getSaleWeights : ( ) => RetailSaleManager . getSaleWeights ( ) ,
411+ clearSale : ( ) => RetailSaleManager . clearSale ( )
412+ } ,
413+
368414 // Printer
369415 printer : {
370416 scan : ( ) => PrinterService . scanDevices ( ) ,
0 commit comments